Learn how to get better insights with a Sitecore Google Analytics and Google Tag Manager integration.
Sitecore is a robust content management system for enterprises. But when it comes to understanding online behaviour, Google Analytics 4 surpasses Sitecore Experience Analytics with its ease of use, features, available reports and custom attribution.
When companies choose Sitecore as their content management system, it is common for them to already be using Google Analytics 4, as well as other connected platforms like Google Ads and Google Search Console.
This article explores how to push data from Sitecore into Google Analytics, using a combination of Sitecore, Google Tag Manager, and Google Analytics.
The Power of Google Tag Manager
Websites generally have a lot of elements that require tracking, such as hero images featuring CTA buttons, embedded links in content, form submissions and e-commerce information. Google Tag Manager has simplified this process, from one that was previously manual, to one that is far more streamlined. Google Tag Manager enables the creation of tags that fire based on a specific button ID, class, or CSS selector.
While this method significantly reduces development time, it is not without its flaws. For example, when a site is updated, things like CSS selectors, classes, and IDs may be changed, and this can break your tracking.
Additionally, while Google Analytics 4 reports can attribute where specific button clicks occurred onsite, it remains an arduous task given many buttons have generic calls to action – e.g. “Learn more” or “Enquire Now”. This becomes particularly challenging when multiple buttons on a page use the same text and link to the same page.
Add Google Tag Manager data layer attributes to the Content Editor in Sitecore
While this option requires initial development work, it is a true time-saver and offers the best analysis in the long term. Once additional functionality within the Sitecore Content Editor has been developed, Google Tag Manager data layer values can be manually placed on components.
Sitecore’s user interface allows for GTM attributes to be added to certain components such as buttons or transaction data and these are passed into the Google Tag Manager data layer when the component loads or is clicked.
To keep this article clear, we have presented a simpler example below. However, through this functionality, we can also track plenty of more ‘complicated’ interactions, such as form submissions, e-commerce actions including checkout, add to cart, product impressions, purchase, etc.
The below example demonstrates how this functionality enables components, such as buttons, to be tracked accurately in Google Analytics.
Sitecore Google Analytics Integration
In Marketing We Trust are promoting a Google Analytics Implementation service, and the site features a hero image with the button text “Enquire today.”
In the old set up, the below is what we would see in Google Analytics:
- Event category: Clicks
- Event action: Hero clicks
- Event label: Enquire Now
However, this would pose a challenge in circumstances where greater detail is required to discern between components; for example, when running multiple hero images, buttons with the same call-to-action or A/B testing.
As the new set up allows for precise control over tags, here is what could be displayed in Google Analytics:
- Event category: Clicks
- Event action: Hero clicks
- Event label: 2020 Analytics image: Enquire Now CTA
The defined event label specifies which hero element was clicked, allowing for greater accuracy in Sitecore Google Analytics analysis and attribution.
Below is how the UI appears in Sitecore:
Each attribute has a key:value pair and pushes data into Google Tag Manager’s data layer. For example, an ‘event’ attribute may be set to ‘heroImageClick.’
Within Google Tag Manager, a trigger can be set up to listen for that specific ‘heroImageClick’ event. When it fires, an event hit is sent to Google Analytics that captures the values set up in eventCategory, eventAction, and eventLabel. This streamlines analysing the performance of hero images.
‘eventAction’: ‘Hero clicks’,
‘eventLabel’: ‘Enquire Now’
These events appear in the Google Analytics events report. Specifically, you will need to go to Behavior > Events > Top Events. Further exploration of the Event Category of Clicks and the Event Action of Hero clicks will allow you to see the various Event Labels of the different hero images.
In order to reach this point, further configuration is required in Google Tag Manager. This will allow the data layer attributes coming from Sitecore to be sent to Google Analytics.
Sitecore Google Analytics and Google Tag Manager Integration
Sitecore Google Tag Manager set up
Set up variables
Go to Google Tag Manager and navigate to the Variables menu. We will use one of Google Tag Manager’s in-built variables called ‘event’. Following this, three data layer variables will need to be set up:
In the Variables menu, go to Used-Defined Variables.
Below is a detailed view of eventAction. It is important to note that in a data layer variable, there is a friendly name as well as a data layer variable name. The friendly name can be whatever you want, but the data layer variable name needs to be exactly what you have told your development team.
After creating three variables – eventCategory, eventAction, and eventLabel – you will next create a trigger. Triggers tell tags when to fire.
2. Create a Trigger
In this next step, we are going to create a trigger that listens for an event equal to gaEvent. Go into the Triggers menu, and create a trigger that looks like the below. Save it and note the name you have given it. In the example below, it is called a Generic event trigger because the gaEvent will be used to trigger a lot of different things. Ensure that the event name (highlighted below) is set exactly to gaEvent.
3. Create a Sitecore Google Analytics event-based tag
Finally, we need to create a Google Analytics event-based tag. Create a new tag type of Google Analytics – Universal Analytics. Ensure that you choose Event as the Track Type. Assign the variables you created to Event Category, Event Action, and Event Label. Event Value isn’t required, even though we use it in some cases. Don’t worry about it for now.
4. Set the tag to trigger
Finally, make sure you’ve set the tag to trigger with the trigger you made previously:
In summary, there is significant strength in using a combination of Sitecore, Google Analytics and Google Tag Manager. It offers additional data points that would not otherwise be available without the integration of these platforms. To find out more about how you can unlock the power of these platforms, contact us today.