In this article:
- Introduction
- Step 1: Connect a custom domain to your publication
- Step 2: Configure the publication domain in the Data Stream
- Step 3: Import and configure the Google Tag Manager container settings
- Step 4: Add custom dimensions to Google Analytics
- Step 5: Test the connection
Introduction
This article describes how to connect Google Analytics using Google Tag Manager to start tracking your online publications. Following these instructions will have the online publications tracked in the same Data stream that is tracking your website. This cross-domain configuration is recommended by Google as it helps preserve user journeys. It also supports building catalog-specific audiences to understand how online publications drive conversion and leverage GA4's predictive insights.
⚠️ This setup works best if Enhanced Event Measurement is enabled in the Data stream.
To enable installing tags onto your publications, make sure to connect Google Tag Manager to Publitas, reusing the container that already contains the website's Google Analytics integration.
Step 1: Connect a custom domain to your publications
For Google Analytics to track online publications, embedded on your site, it needs the domain of both the website and publication to match.
Example:
When a publication, hosted on view.publitas.com, is embedded on a website hosted www.mydomain.com, Google Analytics will not record any data. If the embedded publication uses catalog.mydomain.com in its URL, Google Analytics will be able to track the publication.
This is why it is important to make sure that your online publications are published using a subdomain of your site's domain. Once a custom domain is connected to your publication, the embed code is also updated to use the new domain. Make sure to replace any previous embed codes with the new ones.
Click here to learn more about connecting a custom domain to your publications.
Step 2: Configure the publication domain in the Data Stream
- In Google Analytics, locate the property in the Admin section and select Data streams
- Click on the data stream for web and go to Configure tag settings near the bottom
- Select Configure your domains and add a condition where the domain exactly
Step 3: Import and configure the Google Tag Manager container settings
Recording custom events requires custom data. Publitas uses the data layer to feed Google Tag Manager the necessary data. Below are the steps to import the variables, triggers and tags required to install Publitas' preset tracking configuration.
Importing the preset
- Download the container file here
- After selecting the container in Google Tag Manager, go to the Admin section
- Select Import Container and choose the downloaded file from your computer
- Click on Existing workspace and select the desired workspace
- Merge the selected workspace with the content of the imported container, select Rename conflicting tags, triggers, and variables, and click Confirm
Connecting new tags to the GA4 configuration
- Go to the Tags section and connect GA4 - Publitas Virtual Pageview tracking and GA4 - Publitas Event tracking to the website's Measurement ID.
- Complete the setup by deleting the PLACEHOLDER GA4 CONFIG TAG
Exclude existing tags from firing in publications
- Create a new trigger, selecting Page View as the trigger type (or use the copy in the downloadable preset)
- Make sure the trigger fires on Some Page Views and apply the condition Page Hostname - equals - [your custom publication domain]
- Apply the new trigger as an exception to all existing tags that (will) fire on the publications as well, now that the container is also active there.
TIP: Look for tags with the All Pages trigger
Make publication tracking conditional on user consent
If you're using Google Tag Manager to make your tracking solutions conditional on user consent, you might be able to apply the same solution to the new tags for tracking your online publications, since the publications are managed within the same container and hosted on the same domain as the website is.
Step 4: Add custom dimensions to Google Analytics
IMPORTANT: Make sure to disable automatic translation of this page
before completing this step.
Out of the box, all custom events are recorded by Google Analytics. Each event contains a set of event parameters to support advanced filtering of data in reports and dashboards. To record the event parameters as well, you'll need to add them as custom dimensions in Google Analytics.
In Google Analytics, go to Admin > Custom Definitions to create the following set of custom dimensions:
Dimension name | Event parameter | Scope |
Publitas Collection Name | pbl_collection | Event |
Publitas Event Action | pbl_action | Event |
Publitas Event Value | pbl_value | Event |
Publitas Group Name | pbl_group | Event |
Publitas Page Number | pbl_page | Event |
Publitas Product ID | pbl_product_id | Event |
Publitas Product Title | pbl_product_title | Event |
Publitas Publication Name | pbl_publication | Event |
Step 5: Test the connection
Once the setup is completed, your publications will be tracked by Google Analytics. To verify that data is coming in correctly:
- In Google Tag Manager, load any publication that should be tracked by Google Analytics in preview mode (for embedded publications, this does not work if the changes aren't live)
- In Google Analytics, go to Admin > DebugView and look for the events coming in when you browse through and interact with the publication
DebugView in Google Analytics:
Check out all events and parameters recorded for online publications