How To Set Up Cross-Domain Tracking

Interested in tracking your goal conversions over two related sites?

With cross-domain tracking, you can see sessions on two websites tracked as a single session within Google Analytics.

We’ll show you how to easily implement this feature using ExactMetrics.

Why You Need Cross-Domain Tracking

Sometimes your Google Analytics session will span across two or more domains. When this happens, it is useful to track the activity on different domains as one session.

Here’s an in-depth example:

During a Pay-Per-Click (PPC) campaign, a user clicks and lands on your landing page. They take an action and are redirected to your third-party shopping cart, such as Shopify, to checkout.

Without proper cross-domain tracking implemented on your site, Google Analytics will track e-commerce transactions in the following ways:

  • The same user within the campaign will be detected as two different users and two different sessions.
  • Google will detect that someone from your site made a purchase, instead of properly assigning the source of the goal conversion as a user from a PPC campaign.

With cross-domain tracking properly implemented, you will be able to collect data from separate domains and organize them in a single report.

Reading this article will teach you how to add your site domains to ExactMetrics cross-domain tracking settings. Both Universal Analytics (UA) and Google Analytics 4 (GA4) properties can be added to ExactMetrics.

Once you have added your domains to ExactMetrics, you will learn how to add them to your UA property. If you are using GA4 there are different instructions you will need to follow that we cover in a different section of this article.

Prerequisites

  1. On your main WordPress website, you need to install the ExactMetrics plugin. Then authenticate with Google Analytics.
  2. For the other sites that you will use cross domain tracking on, you’ll have to have Google Analytics installed and configured to use the same UA tracking ID (or GA4 measurement ID) as the main site. If your main site is using the UA tracking ID UA-1234567-1, then your other site must also use UA-1234567-1

Adding Your Other Sites for Cross-Domain Tracking in ExactMetrics

Step 1: Click into ExactMetrics » Settings » Engagement, and scroll down to find Cross-Domain Tracking

Step 2: Click “Add Domain” and fill in the fields that appear.

Step 3: Once you’ve added your domain(s), click Save Changes.

Important! It’s not necessary to include the domain ExactMetrics is installed on as a cross-domain site.

For example…

ExactMetrics is installed on yourdomain.com, and you’re going to track example-1.com.

When you add a domain as a cross-domain site, you would only add example-1.com.

Verify Your Source Code for Cross-Domain Tracking

One easy way to test if cross-domain tracking is implemented correctly is to simply look at the source code of your site.

If using a GA4 property:

__gtagTracker(
'config',
'G-XXXXXXXXXX',
{
"forceSSL":"true",
"link_attribution":"true",
"linker":"{\"domains\":[\"myothercooldomain.com\"]}",
"page_path":"location.pathname + location.search + location.hash"
} );

If using a UA property:

__gtagTracker(
'config',
'UA-1234567-1',
{
"forceSSL":"true",
"link_attribution":"true",
"linker":"{\"domains\":[\"myothercooldomain.com\"]}",
"page_path":"location.pathname + location.search + location.hash"
} );

 

You should be able to locate the custom tracking code within the Google Analytics source code to confirm cross-domain tracking is implemented on your site.

Adding Your Other Sites for Cross-Domain Tracking in Universal Analytics

Next, you’ll need to go to your Domain Referral Exclusion List settings to add both domains in your Universal Analytics property.

Step 1: On analytics.google.com head over to Admin » Property Settings » Tracking Info » Referral Exclusion List.

Step 2: Click the + Add Referral Exclusion button.

Step 3: Type in your domain (Excluding subdomains).

Adding Your Other Sites for Cross-Domain Tracking in GA4

You need to update the Configure your domains property setting in GA4 for cross-domain tracking. It’s recommended by Google that this is the setting you use for all of your cross-domain tracking.

Step 1: Login to your GA4 property at analytics.google.com. Then navigate to Admin » Property » Data Streams.

Step 2: Further down the page you will click on Configure tag settings found under the Google tag section.

Step 3: Find Configure your domains and click on it within the Settings section.

Step 4: Next, click Add condition and select the condition that works best for you.

Example: Select Contains in the dropdown and input “thebestwebsite” in the Domain input field.

Now all of these domains would be included in your cross-domain tracking:

  • www.thebestwebsite.com
  • thebestwebsite.com
  • thebestwebsite.org
  • shop.thebestwebsite.com

Step 5: In the upper right of the page, click on the Save button.

Step 6: Now it’s time to test that cross-domain tracking is working. Open a private or incognito browser with no adblocker extensions running. Also, make sure you are not logged in under an administrator or editor account.

Navigate to a page that has a link to the site you included for cross-domain tracking and click on the link.

Check that the URL in the address bar has the “_g1” linker parameter. Your URL should look something like this:

https://www.thebestwebsite.com/?_gl=1*1ej46ag*_ga*NjgwOT

You will need to check the following if you don’t see the “_g1” parameter:

  1. There are no redirect rules applied that are stripping out query parameters
  2. Check to see if there’s any JavaScript code adding event listeners to your links

Common Mistakes with Cross-Domain Tracking

If you experience any issues with cross-domain tracking, verify that your site URL is not added as a cross-domain site.

A common mistake that can happen is:

Your site is example.com and you set example.com as a site under cross-domain tracking.

Simply removing your main site will correct most cross-domain tracking issues in Google Analytics.

You’re done! You’ve implemented cross-domain tracking on your website.

Want to track your form conversions? Check out our guide: How to View Your Form Conversion Stats in ExactMetrics.