Google Tag Manager (GTM)
Steps to implement TrustCommander with Google Tag Manager.
Last updated
Steps to implement TrustCommander with Google Tag Manager.
Last updated
TrustCommander provides a plug-in to integrate with Google Tag Manager. The setup requires technical installation steps.
This method to integrate GTM is outdated. See the page “Consent Mode in GTM” for a smoother integration.
Following you will find the required steps to implement a standard TrustCommander setup.
Choose the default account configuration mode for your account (see Options).
Setup your TrustCommander categories & vendors (see Manage Categories).
Create one or multiple banner templates (see Manage Banner)
Deploy your TrustCommander banner templates to the Commanders Act CDN or on premise target (see Deploy Banner).
Install TrustCommander tag (see below)
Manage GTM tags with TrustCommander (see below).
To install TrustCommander with Google Tag Manager you need to add following JavaScript tag to your website. This snippet can be added in the <head>
of the website or via a custom HTML tag in Google Tag Manager.
tCPrivacyTagManager
hast to be set to "gtm"
. This variable allows TrustCommander to send privacy settings to GTM. It will push a tcConsentChanged
event to the GTM data layer that includes the privacy settings of a visitor in the tcCategoriesConsent
variable. The event is pushed as soon as TrustCommander loads on a page and in case a visitor updates his privacy settings.
{{ privacy_tag_url }}
has to be replaced with your privacy JavaScript tag URL. This URL can be found in the GENERATE & DEPLOY
tab of each privacy banner.
Create a new Trigger
for each TrustCommander category and sub-category. These trigger can then be used to only fire your tags when a visitor accepts a certain TrustCommander category. Create each trigger with following settings:
Visitors will be able to activate or deactivate only sub-categories and not the main category in the banner. In case a category has sub-categories then you have to use the sub-category ID instead of the category ID to play out tags.
There are 4 steps to add triggers to tags in Google Tag Manager (GTM).
In the GTM interface, "Variables" tab, create a custom variable to calculate the status of the consent given by the user: no consent, optout, optin or partially optin. Create a "User Defined" variable.
Variable name: tcCategoriesConsent (the name that will appear in your interface, so you can choose another name)
Variable Type: "Data Layer Variable"
Data Layer Variable Name: tcCategoriesConsent (the variable used by Commanders Act Privacy when you add tCPrivacyTagManager = "gtm" in the website’s source code)
Data Layer version: choose the latest data layer version available
Important: to facilitate the implementation of Privacy rules on your tags that may already have other triggers in place, we recommend that you work with an "exception" logic and follow the implementation process explained below. The logic is to create rules that will not trigger the tag if the category is denied rather than rules that will trigger it if the category is valid.
Configure the trigger as follows:
Trigger name: Retargeting category (this name depends on the category names that you create and the name that you want to be displayed on your interface)
Trigger Type: "Custom Event"
Event name: tcConsentChanged (this is the event sent by the Commanders Act Privacy when you use tCPrivacyTagManager = "gtm" in your website’s source code)
This trigger fires on: "Some Custom Events"
Fire this trigger when an Event occurs and all of these conditions are true: pick the tcCategoriesConsent variable created in the previous step, the operator “equals” (or “contains”), and the name of the category as you declared it in the Commanders Act Privacy interface.
Be careful when you create sub-categories associated to a category: you have to enter the sub-category ID and not the category ID in the Trust commander values
, as the user will be able to activate or deactivate only sub-categories and not the main category in the banner:
Be careful in case you use more then 9 categories and sub-categories. In this case there can be a confusion between e.g. category "2" and category "12" as "2" is included in "12". In this case we recommend to only use category IDs above 10. We are working on an improvement to resolve this.
Name of the trigger: "trust_commander".
Trigger Type: "Custom Event"
Event name: "trust_commander"
This trigger fires on: "All Custom Events"
In the "Triggers" section, start by creating the following trigger that allows you to not activate the tags if the user has not yet given his consent :
If you want your site to be in "default optout" mode (blocking of tags when the visitor arrives on your site, in accordance with the General Data Protection Regulations, the GDPR), you must also make the following configuration.
Then create a custom tag that you will trigger on all pages (this is the TrustCommander event listener) in the "Tags" section:
Name of the tag: "Trust commander event listener"
Trigger Type: "Custom HTML"
HTML: copy and paste the following code :
Triggering : "All pages"
In the GTM interface, in the Tags
section, assign the previously created trigger to your tags to fire them based on the TrustCommander categories. These triggers will replace your normal "pageview" trigger.
Field
Value
Variable name
Label that the consent variable has in the GTM interface (recommended: tcCategoriesConsent)
Variable Type
Data Layer Variable
Data Layer Variable Name
tcCategoriesConsent
Data Layer version
Choose the latest data layer version available
Field
Value
Trigger name
Label of the Trigger in the GTM interface (recommended to use TrustCommander category name like "Retargeting category").
Trigger Type
Custom Event
Event name
tcConsentChanged
This trigger fires on
Some Custom Events
Fire this trigger when an Event occurs and all of these conditions are true
tcCategoriesConsent contains
ID of the related TrustCommander category.