> For the complete documentation index, see [llms.txt](https://community.commandersact.com/adloop/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://community.commandersact.com/adloop/vii-adloop-tracking-and-attribution/b.-adloop-script-installation-and-checking/script-installation-on-gtm.md).

# 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](https://3498010832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3KEERJBEyYQ7ZxIIMK79%2Fuploads%2Fgit-blob-e34ac86788be9669097e497d0040f487033a7fdb%2Fimage-20240222-100528.png?alt=media)

* 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

![](https://3498010832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3KEERJBEyYQ7ZxIIMK79%2Fuploads%2Fgit-blob-404d775ae535687aeb7b45b06da9652ecdbd31b7%2Fsetup_doc_3.png?alt=media)

* 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

![](https://3498010832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3KEERJBEyYQ7ZxIIMK79%2Fuploads%2Fgit-blob-c74b5ffe7de9ff29f59dd52d719d011231512677%2FiB0STOwFDDybxE8j8XYy5yd_MqkPhWYhvsPSq3oqFboY5b2EL98MxVy1jG3H88G7R13xyDfZCqejhgNU1KWebf-CQTamIaoBLTM8xzsJYNUgtLvqRlpez8ZhjwD_iihMuOVNc1dDIFFfzpz0dw?alt=media)

* 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

![](https://3498010832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3KEERJBEyYQ7ZxIIMK79%2Fuploads%2Fgit-blob-852c47e96ddf48d82989d9613cd46fdf9effe795%2FWcoqsJxbG35kNBPsgwrkm-MlS27_z29fTNJvT0LxFJNCqZQsId4Es_S7GXUV64jOc3u0hblo0GcvUggEZJDCUO0j29QV7kepmBYukFDpD1mdyp6_vfVycH_0Ygq8L7o7UeupLJm8VsM35gN4bQ?alt=media)

* 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

![](https://3498010832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3KEERJBEyYQ7ZxIIMK79%2Fuploads%2Fgit-blob-0b453d8c4afd3576e901f19d549ad5bee5ba53c1%2F1btBNBkLnjYOHXARWo5L7eADTwSQ5MwhKSdieAO4wUbRaEcqNszq7FwQik7N3FZcW8zyhFVORXJ6G09ZK2pfAsi2RFu_2Re06Moat9rUgtplRsQLvCWyKT2GGdtjDOZba3xLsjnSCCPY2AHnZw?alt=media) \*

* 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

![](https://3498010832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3KEERJBEyYQ7ZxIIMK79%2Fuploads%2Fgit-blob-c91476b35bb08e238888b1087edb4b653753a782%2Fimage-20231117-134234.png?alt=media)

* 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)

![](https://3498010832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3KEERJBEyYQ7ZxIIMK79%2Fuploads%2Fgit-blob-f51391205a5ecf15430e729b1c0d736b49a88aca%2Fimage-20231117-134357.png?alt=media)

* 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

![](https://3498010832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3KEERJBEyYQ7ZxIIMK79%2Fuploads%2Fgit-blob-5932e6beac036d5d249d9a2fdc0bcdbec8f5f65f%2Fimage-20230427-154944.png?alt=media)

* 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 :

![](https://3498010832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3KEERJBEyYQ7ZxIIMK79%2Fuploads%2Fgit-blob-d6f65c8abf5e8c54c6989bb96c12e1079f048737%2Fimage-20240105-151443.png?alt=media)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

![](https://3498010832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3KEERJBEyYQ7ZxIIMK79%2Fuploads%2Fgit-blob-6dd763803dcd85b9ef90ce5e6ba2058368109ea5%2Fimage-20240105-151632.png?alt=media)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

![](https://3498010832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3KEERJBEyYQ7ZxIIMK79%2Fuploads%2Fgit-blob-feadad9b315876e1cb78c066a3a1002a56dbf56d%2Fimage-20230427-154951.png?alt=media)
