Skip to content

didomi/gtm-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Didomi custom template for Google Tag Manager

GTM template for Didomi

This template integrates with GTM Consent APIs to allow consent mode and settings in Tag Manager. It is part of the Tag Manager Community Template Gallery.

Table of contents

Didomi clients

The idea behind enabling and using GTM templates is to share with all Didomi clients a proven and more frictionless way to interact with Google Consent Mode. This template allows Didomi's clients to create a tag with a simple upload process, so that their websites have Google Consent Mode enabled.

To better understand how to setup and enable GTM within Didomi's SDK, please refer to https://developers.didomi.io/cmp/web-sdk/third-parties/custom-integrations/tag-managers/google-tag-manager

Developers

The official GTM documentation regarding templates can be found here https://developers.google.com/tag-manager/templates

Loading the template in a test account

In order to use this GTM template (Didomi CMP), you will need to create a new tag and associate the template with at least one trigger.

Creating a new tag

After accessing your Google Tag Manager account and selecting a workspace (we use the Default Workspace for testing purposes),

  1. Click the "New Tag" button as shown here,

uploading_template_00

Or navigate to the "Tags" tab, and click on the "New" button at the top right side of the tags table. uploading_template_00a

  1. Use a relevant name for the new tag ("Didomi CMP" was used for this example) and hit the "Tag Configuration" card.

uploading_template_01

  1. From that screen you should have access to all the templates in the Community Template Gallery, including the "Didomi CMP" one. Look for it and load it.

uploading_template_02

At this point you should have access to the template UI - which includes two checkboxes to set the desired default status for GCM. uploading_template_03

Associating a trigger to a tag

We want our tag to be fired on all pages. In order to achieve that,

  1. Click on the "Triggering" card to choose a trigger so that the tag fires.

associating_trigger_00

  1. Select the "All pages" trigger

Screen Shot 2021-08-05 at 10 28 38 AM

  1. Save the tag. Here it is where you will choose the default values for Analytics and Ad storage

Screen Shot 2021-08-05 at 10 29 00 AM

How to code/test it on a website

Previewing the tag on a website

In order to test the tag on a website, you can make use of the "Preview" feature of the GTM platform. You can find a "Preview" button at the top right of the GTM nav bar menu. preview_00 Note that for the example above, three tags are active("Analytics Demo", "Didomi CMP Test" and Google Analytics GA4 configuration") and one tag is paused("Track Consent Value")

You will be prompted the following screen where you can setup the URL of the website you can to test the tag on. We used https://sandbox.didomi.io/gtm.html for our tests. Clicking continue opens the "Tag Assistant" website. preview_01

The tag assistant is a live tool that can help tremendously with debugging your tags and/or templates.

We can see that the tag we created is in fact being fired during the initial load of the site. Screen Shot 2021-08-05 at 10 32 19 AM

Submitting the tag on a website

Once the testing/previewing process has been sucessful, you can "Submit" a tag to a website so that it goes live.

In this case, click on the "Submit" button at the top right of the GTM nav bar menu. preview_00

How to write and run tests

Unit tests can be written and run per template. You will find a "Tests" tab in the Template Editor where you can do so. tests_00

A sucessfully ran test-suite looks like this tests_01

You can follow this documentation to better understand unit testing for templates https://developers.google.com/tag-manager/templates/tests

And these are the Test APIs that work with GTM Sandboxed Javascript https://developers.google.com/tag-manager/templates/api#test_apis

Editing this template

Uploading a template.tpl file

If you need to load a template.tpl of this repo into GTM,

  1. Get a copy of this repo on your local environment.

  2. Go to the "Templates" tab and click on "New"

Screen Shot 2021-08-05 at 10 55 14 AM

  1. At the top right of the template editor menu, choose "Import"

Screen Shot 2021-08-05 at 10 58 11 AM

  1. Navigate to the template.tpl file in your local environment. Click "save" and then "continue".

Screen Shot 2021-08-05 at 10 50 15 AM

Screen Shot 2021-08-05 at 10 50 22 AM

The template should load correctly, Screen Shot 2021-08-05 at 10 57 58 AM

Updating metadata.yaml

Everytime the template.tpl is updated and you would want the Community Template Gallery version to reflect those changes, the medatada.yaml file should also be updated. The sha value must reference the specific template.tpl file that you want to publish. Don't forget to update this value correctly with every new version!

See https://developers.google.com/tag-manager/templates/gallery#metadatayaml

Updating the gallery version

After the metadata.yaml file has been updated, the gallery version of the template will reflect any changes within 2 to 3 days typically. The template users will be notified of said changes and they will have the option of automatically update to the latest version.

See https://developers.google.com/tag-manager/templates/gallery

About

GTM template for Didomi

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages