---
title: Integrating SiteSpect with GA4 using GTM
description: The following document describes how to send SiteSpect WATTS data to GA4 using Google Tag Manager with each page_view event
---

[Skip to content](https://doc.sitespect.com/knowledge/integrating-sitespect-with-ga4-and-gtm#main-content)

English

Show submenu for translations

![Monetate-Logo-Full-Color-1](https://doc.sitespect.com/hs-fs/hubfs/Monetate-Logo-Full-Color-1.png?width=340&height=49&name=Monetate-Logo-Full-Color-1.png)

- [A/B Testing](https://www.sitespect.com/testing-and-experimentation/)
- [Personalization](https://www.sitespect.com/personalization-targeting/)
- [Recommendations](https://www.sitespect.com/recommendations/)

Open main navigation

Close main navigation

- [A/B Testing](https://www.sitespect.com/testing-and-experimentation/)
- [Personalization](https://www.sitespect.com/personalization-targeting/)
- [Recommendations](https://www.sitespect.com/recommendations/)
- English
  
  Show submenu for translations

 How can we help you?

- There are no suggestions because the search field is empty.

1. [Knowledge Base](https://doc.sitespect.com/knowledge?hsLang=en)
2. [Third-Party Integration](https://doc.sitespect.com/knowledge/third-party-integration?hsLang=en)
3. [Google](https://doc.sitespect.com/knowledge/third-party-integration?hsLang=en#google)

# Integrating SiteSpect with GA4 using GTM

## The following document describes how to send SiteSpect WATTS data to GA4 using Google Tag Manager with each page\_view event

### Step 1: WATTS Global Site Variation

![](https://doc.sitespect.com/hubfs/image-png-Jul-19-2023-08-22-24-7644-PM.png)

**Replacement HTML**

```
<head>
<script>
  var ssWATTS={"ssGUID":"__SS_GUID__","ssCounted":"__SS_LISTCAMPAIGNCOUNTED{__SS_VGID__}{,}__"};
</script>
```

Notes:

- Under Advanced Settings \> Apply Based on Campaign Assignment \> "Test traffic only (and user is counted)". If you want to pass over the SiteSpect GUID (ssGUID) with all test traffic even if the user is not counted yet, select "Test traffic only (regardless of whether user is counted or not)". This will ensure there is a ssGUID but you could get a blank for the ssCounted value if the user has not been counted in any campaign yet. 
- SS\_LISTCAMPAIGNCOUNTED is the most common macro. See all [WATTS macros](https://doc.sitespect.com/knowledge/build?hsLang=en#watts) for more.
- Please work with your SiteSpect Team to determine the best SiteSpect settings and data to send to GA. This document provides an example of the base level setup.

### Step 2: dataLayer and GTM code Global Site Variation

![](https://doc.sitespect.com/hubfs/image-png-Jul-19-2023-08-25-31-3876-PM.png)

**Replacement HTML**

```
<script>
window.dataLayer = window.dataLayer || [];
if(window.ssWATTS && ssWATTS.ssGUID){
    dataLayer.push({
        'event': 'sitespect_watts',
        'sscampaigns': ssWATTS.ssCounted,
        'ssguid': ssWATTS.ssGUID
    });
}
</script>
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-ABC123');</script>
<!-- End Google Tag Manager -->
</head>
```

Notes:

- Generate the Google Tag Manager code from GTM. This could could be inserted on your site separately in which case you just want to ensure that SiteSpect injects the dataLayer block above it.
- Pre-populating the dataLayer with WATTS data is a valid option called out in GTM documentation.
- The dataLayer could optionally be loaded with WATTS data from within GTM.

### Step 2a: SPA Type Sites - Callback Setup

There are two additional steps that need to be taken when setting up for a SPA type site. This ensures that the WATTS variables and dataLayer get updated when a user gets counted on a page that did not make a full request to the server.

1. In Configuration \> Site Settings \> Features, the "Client-Side WATTS Template" will need to be updated to:
   
   ```
   {"ssGUID":"__SS_GUID__","ssCounted":"__SS_LISTCAMPAIGNCOUNTED{__SS_VGID__}{,}__"}
   ```
   
   *This will update will need to be done by SiteSpect*.
2. In your Global Variation that is normally named "EventTrack ·  SPA ·  SiteSpect Libraries", you will want to add a bit of code for the callback just above the ending \</script\> tag.
   
   ```
   SS.Require(function() {
       if (window.ss_dom_var && ss_dom_var.setAsmtCallback) {
           ss_dom_var.setAsmtCallback(function(watts_object) {
               if(window.ssWATTS && ssWATTS.ssGUID){
                   ssWATTS.ssGUID = watts_object['ssGUID'];
                   ssWATTS.ssCounted = watts_object['ssCounted'];
                   if(window.dataLayer){
                       dataLayer.push({
                           'event': 'sitespect_watts',
                           'sscampaigns': ssWATTS.ssCounted,
                           'ssguid': ssWATTS.ssGUID
                       });
                   }
               }
           });
       }
   });
   ```

   This is also described here: [https://doc.sitespect.com/knowledge/watts-for-single-page-applications-and-client-side-variations](https://doc.sitespect.com/knowledge/watts-for-single-page-applications-and-client-side-variations?hsLang=en)

### Step 3: Create Google Tag Manager Tags and Variables

There are two tags and variables you need to create.

![](https://doc.sitespect.com/hs-fs/hubfs/image-png-Jun-24-2024-06-06-49-5857-PM.png?width=688&height=38&name=image-png-Jun-24-2024-06-06-49-5857-PM.png)

![](https://doc.sitespect.com/hs-fs/hubfs/image-png-Jun-24-2024-06-07-37-1540-PM.png?width=688&height=37&name=image-png-Jun-24-2024-06-07-37-1540-PM.png)

![](https://doc.sitespect.com/hubfs/image-png-Jul-19-2023-08-40-11-1532-PM.png)

#### Tags

1. Create a New tag and name it, e.g. "All Pages - Page Tracking".   
   Select Google Tag for the Tag Type  
   Select All Pages for Triggering  
   ![](https://doc.sitespect.com/hs-fs/hubfs/image-png-Jun-24-2024-06-01-13-2537-PM.png?width=305&height=409&name=image-png-Jun-24-2024-06-01-13-2537-PM.png)  
   References:  
   \- [Set up your Google tag](https://support.google.com/tagmanager/answer/12002338)  
   \- [Announcement: Google tag and Tag Manager](https://support.google.com/tagmanager/answer/13543899)  
   \- [\[GA4\] Find your Google tag ID](https://support.google.com/analytics/answer/9539598)
2. Create the two Variables as shown below prior to creating the final tag.
   
   Create a New tag and name it "SiteSpect WATTS Event".   
   Select Tag Configuration \> Google Tag  
   Create an Event Parameter for each. The + icon to the right of the Value column should find each one that was created as a User-Defined Variable
   
   Configure a Trigger to use a Custom Event  
   ![](https://doc.sitespect.com/hubfs/image-png-Jul-19-2023-08-48-53-3837-PM.png)

#### Variables

- Create a User-Defined Variable for each of the dataLayer event parameter key names.  
  ![](https://doc.sitespect.com/hubfs/image-png-Aug-17-2022-07-03-22-62-PM.png)

### Step 4: Create Custom Dimensions in GA4

- Configure \> Custom Definitions \> Custom Dimensions \> Create Custom Dimensions \[button\]
- Create a Custom Dimension for each Event Parameter  
  ![](https://doc.sitespect.com/hubfs/image-png-Jul-19-2023-08-55-40-3572-PM.png)
- Type in the Event Parameter (this will be an available field when creating a new Dimension)  
  ![](https://doc.sitespect.com/hubfs/image-png-Aug-17-2022-07-28-11-96-PM.png)

- [Get Started](https://doc.sitespect.com/knowledge/get-started?hsLang=en#main-content)

    - [SiteSpect Support](https://doc.sitespect.com/knowledge/get-started?hsLang=en#sitespect-support)
    - [Overview Information](https://doc.sitespect.com/knowledge/get-started?hsLang=en#overview-information)
    - [Intro to SiteSpect](https://doc.sitespect.com/knowledge/get-started?hsLang=en#intro-to-sitespect)
    - [Account Setup](https://doc.sitespect.com/knowledge/get-started?hsLang=en#account-setup)
    - [Artificial Intelligence](https://doc.sitespect.com/knowledge/get-started?hsLang=en#artificial-intelligence)
- [Dashboard](https://doc.sitespect.com/knowledge/dashboard?hsLang=en)
- [Build](https://doc.sitespect.com/knowledge/build?hsLang=en#main-content)

    - [Setting Up a Campaign](https://doc.sitespect.com/knowledge/build?hsLang=en#setting-up-a-campaign)
    - [Create a Client-Side Campaign](https://doc.sitespect.com/knowledge/build?hsLang=en#create-a-client-side-campaign)
    - [Create a Server-Side Campaign](https://doc.sitespect.com/knowledge/build?hsLang=en#create-a-server-side-campaign)
    - [Metrics](https://doc.sitespect.com/knowledge/build?hsLang=en#metrics)
    - [Audiences](https://doc.sitespect.com/knowledge/build?hsLang=en#audiences)
    - [Triggers](https://doc.sitespect.com/knowledge/build?hsLang=en#triggers)
    - [Variations](https://doc.sitespect.com/knowledge/build?hsLang=en#variations)
    - [Traffic Management](https://doc.sitespect.com/knowledge/build?hsLang=en#traffic-management)
    - [Preview](https://doc.sitespect.com/knowledge/build?hsLang=en#preview)
    - [Factors](https://doc.sitespect.com/knowledge/build?hsLang=en#factors)
    - [Advanced Settings](https://doc.sitespect.com/knowledge/build?hsLang=en#advanced-settings)
    - [Omnichannel](https://doc.sitespect.com/knowledge/build?hsLang=en#omnichannel)
    - [Regular Expressions (Regex)](https://doc.sitespect.com/knowledge/build?hsLang=en#regular-expressions-regex)
    - [WATTS](https://doc.sitespect.com/knowledge/build?hsLang=en#watts)
    - [Recommendations](https://doc.sitespect.com/knowledge/build?hsLang=en#recommendations)
- [Monitor](https://doc.sitespect.com/knowledge/monitor?hsLang=en)
- [Analyze](https://doc.sitespect.com/knowledge/analyze?hsLang=en#main-content)

    - [Data Export and Integration](https://doc.sitespect.com/knowledge/analyze?hsLang=en#data-export-and-integration)
    - [SiteSpect Reports](https://doc.sitespect.com/knowledge/analyze?hsLang=en#sitespect-reports)
- [Site](https://doc.sitespect.com/knowledge/site?hsLang=en#main-content)

    - [Tools](https://doc.sitespect.com/knowledge/site?hsLang=en#tools)
    - [Configuration](https://doc.sitespect.com/knowledge/site?hsLang=en#configuration)
- [Developers](https://doc.sitespect.com/knowledge/developers?hsLang=en#main-content)

    - [API Reference](https://doc.sitespect.com/knowledge/developers?hsLang=en#api-reference)
    - [Code Samples](https://doc.sitespect.com/knowledge/developers?hsLang=en#code-samples)
    - [Tips & Tricks](https://doc.sitespect.com/knowledge/developers?hsLang=en#tips-tricks)
- [Mobile](https://doc.sitespect.com/knowledge/mobile?hsLang=en)
- [Implementation, Deployment, and Security](https://doc.sitespect.com/knowledge/implementation-deployment-and-security?hsLang=en#main-content)

    - [How does SiteSpect work with CDNs?](https://doc.sitespect.com/knowledge/implementation-deployment-and-security?hsLang=en#how-does-sitespect-work-with-cdns)
    - [Single Tenant Implementations](https://doc.sitespect.com/knowledge/implementation-deployment-and-security?hsLang=en#single-tenant-implementations)
    - [Security Features](https://doc.sitespect.com/knowledge/implementation-deployment-and-security?hsLang=en#security-features)
    - [Deployment and Implementation Overview](https://doc.sitespect.com/knowledge/implementation-deployment-and-security?hsLang=en#deployment-and-implementation-overview)
    - [SiteSpect Engine & Admin API](https://doc.sitespect.com/knowledge/implementation-deployment-and-security?hsLang=en#sitespect-engine-admin-api)
- [Third-Party Integration](https://doc.sitespect.com/knowledge/third-party-integration?hsLang=en#main-content)

    - [Google](https://doc.sitespect.com/knowledge/third-party-integration?hsLang=en#google)
    - [Zuko](https://doc.sitespect.com/knowledge/third-party-integration?hsLang=en#zuko)
- [Troubleshooting](https://doc.sitespect.com/knowledge/troubleshooting?hsLang=en)
- [Releases](https://doc.sitespect.com/knowledge/releases?hsLang=en#main-content)

    - [Superfresh](https://doc.sitespect.com/knowledge/releases?hsLang=en#superfresh)
- [Feedback](https://doc.sitespect.com/knowledge/feedback?hsLang=en)

- [A/B Testing](https://www.sitespect.com/testing-and-experimentation/)
- [Personalization](https://www.sitespect.com/personalization-targeting/)
- [Recommendations](https://www.sitespect.com/recommendations/)

[![Monetate-Logo-Full-Color-1](https://doc.sitespect.com/hs-fs/hubfs/Monetate-Logo-Full-Color-1.png?width=200&height=29&name=Monetate-Logo-Full-Color-1.png "Monetate-Logo-Full-Color-1")](http://monetate.com)

<https://www.facebook.com/> <https://www.twitter.com/> <https://www.instagram.com/> <https://podcasts.apple.com/> [mailto:email@email.com](mailto:email@email.com)

Copyright © 2026, Monetate