The following article details the Tag Manager integration with Google Tag Manager (GTM).
Configure and implement Tag Manager with GTM
This guide outlines the steps to configure and implement Tag Manager with Google Tag Manager (GTM). The integration allows you to use AAS Tag Manager's functionality across different GTM containers.
General Procedure
- Configure and Generate Tag Manager Code in AAS
Begin by configuring and generating the Tag Manager code within your Ad Server (AAS). Refer from this article for reference: Work with Tag Manager - Share the Tag Manager Code
Provide the generated Tag Manager code to the GTM administrator. - GTM Administrator Actions
In Google Tag Manager, the administrator should perform the following steps:- Open the GTM account associated with your website.
- Create a new tag by following these steps:
- Name the tag "Tag Manager"
- Select "Custom HTML" as the tag type.
- Paste the Tag Manager code, provided by AAS, into the HTML box.
- Select the Support document.write check box.
Note:
The Support document.write option is not required for implementing Tag Manager because it does not use document.write directly. However, third-party scripts, that are executed by a rule match, might contain document.write, therefore, it is recommended to select this check box to avoid any unexpected runtime errors. -
Select the default All Pages in the Triggering section.
-
Publish the GTM.
- Open the GTM account associated with your website.
Passing Variables to Tag Manager
It is possible to pass variables to Tag Manager to use for sales conversion activities and dynamic retargeting activities.
GTM Setup
- Follow the steps under Configure and Implement Tag Manager with GTM.
- GTM admin adds the following data layer before the existing implementation of tag manager code. Have the GTM admin use the correct variable name where {{GTMvariableName}} should be replaced.
<script type = "text/javascript">
var SizmekDataLayer = {
"OrderID": "{{GTMvariableName}}",
"ProductID": "{{GTMvariableName}}",
"ProductInfo": "{{GTMvariableName}}",
"Quantity": "{{GTMvariableName}}",
"Value": "{{GTMvariableName}}",
"Variable 1":{{GTMvariableName}}",
"Variable 2":{{GTMvariableName}}",
"Variable 3":{{GTMvariableName}}"
}
</script> - Publish in GTM.
AAS Setup
- Create Variables each named OrderID, ProductID, ProductInfo, Quantity & Value. Select Data Layer Variable as type. Set Variable Name in Data Layer to be the same with the Variable name. Tag Manager also supports passing custom variables (Variable_1, _2 and _3 on the sample code above). To setup Custom variables, create them under the Tag Manager, as described here, and add them to the code for the SizmekDataLayer.
- Assign the created variables to activity parameters in your conversion activity. Make sure your conversion activity is attached to an activity rule.
- Publish Tag Manager.
Fire Tag Manager on Button Clicks and Pass Data using GTM
In this process, the AAS Tag Manager is triggered when a website button is clicked. The data linked to this button click event is collected and transmitted through Google Tag Manager (GTM). This outlines how to effectively manage data tracking on a website using both AAS Tag Manager and GTM, ensuring seamless data flow and analysis.
GTM Setup
- In GTM, the administrator creates a User-Defined Variable.
- Give the variable a name.
- Select the Auto-Event Variable as the variable type.
- Select Element ID from the Variable Type list, and click SAVE.
- In GTM, administrator creates a new tag.
- Name the Tag TM_generateRequest and choose Custom HTML as tag type.
- Paste the following into the HTML box. Have the GTM admin use the correct variable name where {{GTMvariableName}} should be replaced. Note that adding variables is optional, and the sample code below is used for illustration purposes.
<script>
versaTagObj.onready(function () {
versaTagObj.clearActivityParam();
versaTagObj.setActivityParam("OrderID", {{GTMvariableName}});
versaTagObj.setActivityParam("ProductID", {{GTMvariableName}});
versaTagObj.setActivityParam("ProductInfo", {{GTMvariableName}});
versaTagObj.setActivityParam("Quantity", {{GTMvariableName}});
versaTagObj.setActivityParam("Value", {{GTMvariableName}});
versaTagObj.generateRequest("http://www.{{Page Hostname}}/{{VariableName}}");
});
</script>- GTM automatically replaces {{Page Hostname}} with the site’s domain (and subdomain, if applicable).
- The reference {{VariableName}} is used to illustrate the example. The actual value within the brackets {{}} should be replaced by the name given to the variable in step 1. For example, If the variable was named SubmitButtonClick, then the reference to it in the generateRequest method would be:
versaTagObj.generateRequest("http://{{Page Hostname}}/{{SubmitButtonClick}}");
- Under Advanced Settings > Tag Sequencing perform the following actions:
-
Select Fire a tag before TM_generateRequest fires and select Tag Manager as the setup tag.
-
Select Don’t fire TM_generateRequest() if Tag Manager fails.
This will ensure that TM_generateRequest() only fires after Tag Manager has successfully fired.
-
- Add a trigger to initiate the firing of the TM_generateRequest tag, commonly on user clicks:
-
Add a new trigger using All Elements type.
-
Select Some Clicks.
-
Define firing conditions based on the elementID (taken from the Page source/HTML tag properties) that is stored by the variable created in step 1.
-
Select Save.
-
- Publish the GTM.
AAS Setup
- Create an activity rule, in the IF section select Page URL and Equals one of the following. Input the elementID defined in step 4c of the GTM setup.
- Add a conversion activity to the rule. Make sure the type is Amazon Ad Server’s Conversion - Sales
- Publish Tag Manager
Comments