# Script installation on GTM

With Google Analytics UA

* Go to the "Variables" section
* Make sure the Container ID is listed under the Build-In Variables
  * If not, click “Configure”, search for Container ID under “Utilities” and enable it

![image-20240222-100528.png](/files/Fm5J43ywJ9fNQSS3d9YM)

* Create "User defined variables" following this scheme:
  * Type of variable: Data layer variable
  * Name of the data layer variable: indicate the value you set up in your custom dimension on GA4 in the event parameter field (ex: adloop\_click\_1).
  * And give it an adloop related name
  * Repeat these operations for all custom dimensions created in GA

![](/files/Im5E016NhTX0y7HhIrkQ)

* Open the configuration of the "Google Analytics settings" variable,&#x20;
* In "More Settings -> Custom Dimensions, click on "Add Custom Dimension"
* Fill in the following information:
  * Index: XX (where "XX" is the index of the dimension created on GA)
  * Dimension value: {{adloop\_click\_XX}} (Use the brick to choose the previously created variable)
  * Repeat these operations for all variables created in GTM

![](/files/GmuFm7xDM0oApAurtwmL)

* Go to the "Tags" section and add a new tag of type "Custom HTML", with the name "Adloop tag".
* Copy and paste the content provided on the Adloop interface into the "HTML" field of the tag
* Save the tag without trigger

![](/files/Gax6PJN4duxuyjXR7q0k)

* Open the configuration of the Google Analytics tag with the largest trigger ("All pages" or “Pageviews” for example).&#x20;
* In the advanced settings of this tag, in "Tag sequencing", check "Trigger a tag before Google Analytics is triggered" and choose the "Adloop tag" previously created

![](/files/KJsyGl3S07RU9cEIOpjb) \*

* Check if the script is working without error in the preview mode (find our documentation \[\[here|Checking-that-the-script-is-triggered]]), then deploy the new version.

Google Analytics 4

* Make sure the Container ID is listed under the Build-In Variables
  * If not, click “Configure”, search for Container ID under “Utilities” and enable it
* Go to the "Variables" section
* According to the custom dimensions created earlier, create "User defined variables" following this scheme:

  * First one:
  * Type of variable: Data layer variable
  * Name of the data layer variable name : adloop\_click\_1
  * Give the variable an Adloop related name
  *

  ```
  ![](/files/eov6VBKoZHKLbJX7NTAs)
  ```

  * Second one:
  * Type of variable: Data layer variable
  * Name of the data layer variable: adloop\_click\_1\_meta
  * Give the variable an Adloop related name

![](/files/DB7GQLuN83dUp2T6Idp6)

* Open the configuration of the GA4 Configuration tag (type: Google Tag)
* In "Fields to Set”, click on "Add Row"
* Fill in the following information:
  * Field Name: adloop\_click\_1
  * Value: Use the brick to choose the previously created variable (the 1st one)
  * Add another filed: adloop\_click\_1\_meta
  * Value: Use the brick to choose the previously created variable (the 2nd one)

![](/files/j52SWnZoPSkm1vD9uN3Z)

* Go to the "Tags" section and add a new tag of type "Custom HTML", with the name "Adloop tag"
* Copy and paste the content provided on the Adloop interface into the "HTML" field of the tag
* Save the tag without trigger

![](/files/4SuL64LG38q5xWKV7muL)

* Open the GA4 Configuration tag (type: Google Tag) that was opened in a previous step
* In the advanced settings of this tag, in "Tag sequencing", check "Trigger a tag before this tag is triggered" and choose the "Adloop tag" previously created
* For your GA4 events (purchase, add to cart, view item etc.) set-up on GTM, add the Adloop event parameters & values :

![](/files/YB5BhzFiYu0rlLeTKs7j)adloop\_click\_1 and for the value select the first user defined variable you created previously using the brick button

adloop\_click\_1\_meta and for the value select the second user defined variable you created previously using the brick button

![](/files/lFIdWV2OLHKXzSRrJPQS)Note: the name of the value between {{ }} depends on how you named your user defined variable ; it might be different from the screenshot above.

* Check that all your events (add to cart, purchase etc.) are triggered after the pageview is sent. Otherwise our script won’t be able to catch those events.
* Deploy the new version

![](/files/0eYhBdFOwJ0wx4l2aasU)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://community.commandersact.com/adloop/vii-adloop-tracking-and-attribution/b.-adloop-script-installation-and-checking/script-installation-on-gtm.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
