Integrating with GTM

Using Metomic with Google Tag Manager

1. Ensure the metomic embed script is installed

Please note: Metomic will load and display faster if you install it directly into the head of your webpage, as described in the section Installing the Consent Manager. This will not affect Metomic's ability to interact with GTM

a) Create a tag

In your GTM project, create a new tag by clicking New → Custom HTML Tag
In the HTML field, enter your Metomic embed snippet:

Be sure to replace __YOUR_CLIENT_ID__ with your clientId, which you can find here

  (p[a].q=p[a].q||[]).push(arguments)},p[a].l=1*new Date();c=r.createElement(i),
  })(window, document, 'script', '', 'Metomic');
  Metomic('load', { projectId: '__YOUR_CLIENT_ID__' });

To help identify the tag later, ensure you provide a name at the top of the page (e.g. "Metomic Embed Code")

b) Enable the tag on all pages

Under Triggering, choose All Pages as the trigger

c) Save your changes

Your configuration is now ready to save, and should look something like this:

gtm step 1

d) Publish your changes

Once you've saved the tag, ensure you click SubmitPublish to push the change live to your site.

2. Set up Metomic variable and triggers

Please note: This section will show you how to manually set up GTM. Automated GTM integration removes the need for this step, but is not yet publicly available. For more information, please get in touch

In order to block a problematic tag from running until consent is given, you will need to modify that tag's configuration. This will usually involve changing the trigger from "All Pages" to "Metomic:Permit [your-policy]"

To facilitate this, we must create:

  1. A GTM variable which contains a micropolicy slug
  2. GTM triggers which represent your micropolicies

Set up the metomic.micropolicy variable

  1. Click Variables → User-Defined Variables → New
  2. Create a new Data Layer Variable.
  3. Set the Data Layer Variable Name to be metomic.micropolicy
  4. Set the Name of the variable at the top of the screen to metomic.micropolicy

gtm step 2

Set up triggers for your micropolicies

In order to trigger a tag when consent has been granted for a particular micropolicy, you must create a trigger for that policy. For this example, we will create a trigger for the statistics policy:

  1. Click Triggers → New → Custom Event
  2. Set the Event Name to metomic.permit
  3. Under "This trigger fires on", select Some Custom Events
  4. Set a condition of metomic.micropolicy equals statistics

gtm step 3

In manual integration mode, you will need to repeat this step for your other micropolicies.

3. Allocate a trigger to each tag you wish to control

Now that you have triggers set up, you can configure a target tag to only load when the trigger fires.

Under Tags, choose a tag you wish to control. In this example, we'll configure Google Analytics to only run once permission for statistics has been given.

Under Triggering, add the appropriate trigger as set up in step 2. In this case, we'll choose "Metomic.Permit statistics"

gtm step 4

Note: If there is already a "Page View" trigger present for your tag, you will need to replace it with the appropriate Metomic.Permit trigger

Finally, click Publish to push your changes live to your site