Search
Clear search
Close search
Google apps
Main menu
true

How to create Cross-Domain Tracking Variables

If you want to get data from multiple websites into one Analytics report, we recommend setting up cross-domain tracking.

To begin, we’ll need to create two Constant (or reusable) user-defined variables: gaDomain and gaCrossDomains.

Creating the gaDomain variable

gaDomain will write cookies to the highest-level domain by default to ensure you don't lose any data across sub-domains. The gaCrossDomains variable will let you reference a list of domains all at once, rather than having to type out each domain every time you want to update a tag.

 

In the left-hand navigation click “Variables.” Then select “New.” We’ll name the variable gaDomain. Then select the type as “Constant.” We’ll type the value “auto” so that cookies to this variable automatically get written to the highest-level domain. Then click “Create Variable.”

Creating the gaCrossDomains variable

Now that we’ve set up the gaDomain variable, let’s set up the gaCrossDomains variable. In the left-hand navigation click “Variables” again. Select “New.” And then select “Constant.” We’ll name this variable “gaCrossDomains.”

We’ll set the value to The Great Outdoor’s domains: “greatoutdoorsretail.com” and “greatoutdoorstraveladventures.com,” separated by a comma. Then click “Create Variable.”

Adding cross-domain variables to Universal Analytics

Once we’ve set up our cross-domain variables, we’ll need to add them to the Universal Analytics “Page View” tag we installed previously. Click “Tags.” Then select the “Page View” tag we set up earlier.

To set up the cookie domain, under “Configure Tag,” click the “Edit” icon. Then click “More Settings.” Then click “Fields to Set.” And click “Add Field.” In the Field Name area, we’ll type “cookieDomain.” To set the value to the first variable we created, click the Value selector button. Then select {{gaDomain}}.

Now click “Cross Domain Tracking.” Click on the selector for Auto Link Domains. Then select the gaCrossDomains variable we created earlier. Leave the “Use Hash as Delimiter” and “Decorate forms” fields as false. These help you pass query string and form information across multiple domains, so we don’t need to worry about these right now.

Click “Continue.” Then click "Save Tag."

When you publish these changes, you’ll be able to use your Analytics “Page View” tag to track across different domains. You should see real-time traffic in Analytics being captured from each domain that you’re tracking.

Was this article helpful?
How can we improve it?
Google Analytics training and support resources

Check out our comprehensive list to learn more about Analytics solutions.