# Integrating with GA4 using Google Tag Manager

Depending on your GA4 setup, you may need to route the Intelligems `experience_impression` event from the Data Layer to GA4 using Google Tag Manager. This step-by-step guide will help you set up the Tag in Google Tag Manager to do this.

1. **Add an Intelligems setting so that the GA4 event is added to the Data Layer**. In your theme code, above the Intelligems script in the \<head> of the theme, add:\\

   ```html
   <script>
     window.igSettings = {
       useDataLayer: true
     }
   </script>
   ```
2. In Google Tag Manager (GTM), first create the Variable. Select "Variables" then "New":

   <figure><img src="/files/SLtqWKyDWsZKqI1Z3tyF" alt=""><figcaption></figcaption></figure>
3. Click on "Variable Configuration":

   <figure><img src="/files/4zZW5DctXWikfR6BP9Qb" alt=""><figcaption></figcaption></figure>
4. Choose "Data Layer Variable":\\

   <figure><img src="/files/oRucfPIp3QG47dXrda6r" alt=""><figcaption></figcaption></figure>
5. Enter `exp_variant_string` for Data Layer Variable Name, title the variable `exp_variant_string`, and click Save:\\

   <figure><img src="/files/e79qbfXurN8Ff7J7eM7s" alt=""><figcaption></figcaption></figure>
6. Now create the tag. Click "Tags" then click "New":\\

   <figure><img src="/files/8js2Cs5whdKBQcOTuKFN" alt=""><figcaption></figcaption></figure>
7. Click Tag Configuration:

   <figure><img src="/files/WBXwLGJSWXCiqA1a8hGE" alt=""><figcaption></figcaption></figure>
8. Choose Google Analytics:\\

   <figure><img src="/files/E0rJWOT5GlXvSxmcY2b1" alt=""><figcaption></figcaption></figure>
9. Choose Google Analytics: GA4 Event

   <figure><img src="/files/HhGkTz0xIqhy0j8MwIB0" alt=""><figcaption></figcaption></figure>
10. Enter your GA4 Measurement ID, enter `experience_impression` as the Event Name, enter `exp_variant_string` as the Event Parameter, and choose `exp_variant_string` as the Event Value by clicking on the variable picker icon (choosing the Variable we created in step 5):\\

    <figure><img src="/files/fUnjAf2kGSNzGyAxrbei" alt=""><figcaption></figcaption></figure>
11. Click Triggering:\\

    <figure><img src="/files/qRuSdSAqPDDtyHFlkXHX" alt=""><figcaption></figcaption></figure>
12. Click Trigger Configuration:

    <figure><img src="/files/zOLn5gCEuoRz9B2qC7L3" alt=""><figcaption></figcaption></figure>
13. Choose Custom Event:\\

    <figure><img src="/files/sUDPbQ3sYMztc9xPQ60g" alt=""><figcaption></figcaption></figure>
14. Enter `experience_impression` for Event Name, title the trigger `experience_impression` , and click Save:\\

    <figure><img src="/files/UoVwKq88OQ7inOCljmMw" alt=""><figcaption></figcaption></figure>
15. Click Submit:\\

    <figure><img src="/files/ygVcC5co5jNlibzewDPd" alt=""><figcaption></figcaption></figure>
16. Click Publish:\\

    <figure><img src="/files/QSbaWsR6dpLVvkflCg9X" alt=""><figcaption></figcaption></figure>
17. Give the version a name and click Continue:\\

    <figure><img src="/files/Pfp81jrWLcJ9MSiM1M2Q" alt=""><figcaption></figcaption></figure>


---

# 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://docs.intelligems.io/integrations/google-analytics-4-integration/integrating-with-ga4-using-google-tag-manager.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.
