So, you want to move your tags from Google Tag Manager (GTM) to Matomo Tag Manager (MTM)? MTM has many of the same functionalities as GTM, but there are some key differences to keep in mind.

The process of migrating

Migrating from GTM to MTM is currently a manual process because there are enough differences and quite a bit of complexity.

You probably want to start by creating your container in MTM and making sure you have all of the environments you’re used to using. Once that’s done, you can proceed with the following:

  • Look through your list of GTM variables and try to create similar ones in MTM. A good place to start becoming more familiar with MTM variables is the Variables user guide.
  • Then, look through all of your GTM triggers and try to duplicate them in MTM. You can find details about MTM triggers in the Triggers user guide.
  • Once your variables and triggers are in place, you can try to duplicate all of your GTM tags in MTM. Read up on MTM tags in the Tags user guide.
  • Copy the MTM install code and insert it near or in place of the GTM snippet in your website’s HTML header. For more information, you can look through the Install a tag manager container FAQ.
  • You should should then be ready to preview and debug your tags. You can read about that in the Preview/debug FAQ.
  • If everything looks good, you can create a new version and publish it. That process is described in the Versions and publish user guide.

Side by side comparison

Google Tag Manager Matomo Tag Manager
Navigation Both top and left navigation bars Left navigation bar
Environments Defaults are ‘Live’ and ‘Latest’. Configuration is in the Admin tab. Defaults are ‘live’, ‘staging’, and ‘dev’. Configuration is found in the main Administration gear icon > System > General Settings > Tag Manager.
Containers Allows multiple workspaces and can be exported to JSON from the Admin tab. No workspaces, but multiple users can manage a container. Exporting to JSON is done from the view titled Manage Versions, which is accessible from the Versions option in the left navigation pane.
Versions Yes. A deleted version can be restored. Yes. Once a version is deleted, it can no longer be viewed by the application.
Tags Over 50 types Over 20 types. Much can be accomplished with a custom HTML tag. If you need a specific type of tag, you or a colleague are welcome to code a new tag template. If neither of those options work, you might consider contacting support and have them log an issue to have your desired tag implemented.
Triggers Yes Yes. The options aren’t exactly the same, but they’re comparable.
Pre-defined variables Around 40 built-in variables. Only about 5 display by default and it has to be configured to show more. Around 60 pre-configured variables. All options always display.
Variable types Around 20 Over 10, but the Custom JavaScript allows for quite a bit of versatility. This is also hopefully offset a bit by the larger number of pre-configured variables.
Folders Yes. They can be used to group/organise tags, triggers, and variables. No
Templates Yes No
Code snippet Yes. Usually referred to as the code or container snippet. Yes. Often referred to as the install code.

Basic migration examples

Example 1: Scroll trigger

Say you have a GTM Scroll Depth trigger that looks something like this:

You could create a similar trigger in MTM by doing the following:

  • Click on the Triggers option in the left navigation pane:

  • Click the button to create a new trigger:

  • You will be prompted for the trigger type. Select the Srcoll Reach type:

  • Give the trigger the same or similar name.
  • Select the appropriate Scroll Match type:

  • Fill out any other desired fields and click the button at the bottom of the form to create the new trigger.
  • Your trigger will then be available to use in the creation of a new tag.

Example 2: Custom HTML variable

Say you have a GTM variable using the previously mentioned trigger to display some text like this:

You could create a similar tag in MTM by doing the following:

  • Select the Tags option from the left navigation pane.

  • Click the button to create a new tag.

  • Select the Custom HTML tag type.

  • Set the name of the tag.
  • Populate the Custom HTML field with the desired HTML.
  • Select the trigger created in the previous example.

  • Populate any other values as desired.
  • Click the button, at the bottom of the form, to save the tag.

Example 3: Custom JavaScript variable

Maybe you have a GTM tag that tracks the source URL of any image that’s clicked on the site. You first have a trigger for image clicks something like this:

You have a Custom JavaScript variable something like this:

Your tag then references your trigger and variable something like this:

You could create a similar tag in MTM by doing the following:

  • Click on the Triggers option in the left navigation pane:

  • Click the button to create a new trigger:

  • You will be prompted for the trigger type. Select the All Elements Click type:

  • Give the trigger the same or similar name.
  • In the Only trigger when (optional) section, click on the select to choose the variable to restrict by:

  • You can then either expand the Clicks type group or search for ‘Click n’ and select the Click Node Name option:

  • Leave the operator as equals and set the value as ‘img’ like this:

  • Fill out any other desired fields and click the button at the bottom of the form to create the new trigger.
  • Next, select the Variables option from the left navigation pane:

  • Set the name of the variable.
  • Set the value in the JavaScript Function input to the following:

    function () { return TagManager.dom.getElementAttribute(TagManager.dataLayer.get('mtm.clickElement'), 'src'); }

    If you’d like more information about what this JavaScript is doing, you can look at the Tag Manager JavaScript API documentation.
  • Fill out any other desired fields and click the button at the bottom of the form to create the new variable.
  • Select the Tags option from the left navigation pane.

  • Click the button to create a new tag.

  • Select the Matomo Analytics tag type.

  • Set the name of the tag.
  • Assign a Matomo configuration variable using the drop down.
  • Set the name of the tag.
  • Select Event as the Tracking Type:

  • Populate the event category and action similar to how they were set in GTM. You can use the button on the side of the action input to select the variable created earlier:

  • Change the drop down that defaults to Pageview to the trigger created previously:

  • Click the button, at the bottom of the form, to save the tag.

Previous FAQ: How do I use the Matomo Tag Manager with SharePoint Classic sites?