1

I have 2 different domains - say - abc.example & xyz.example. Both domains point to the same server (same A record, same shared hosting account).

Now if I want to setup google analytics for both the domains, how would I do it? Both the sites use same source code and content.

  • Do you want abc and xyz to be treated as the same site in GA, or as two different sites? – Reve Jan 29 at 14:14
1

The easy way is to create 2 views and for both of them set filters on both of them that matches specific url if it is presented like this just do custom filter that includes "abc" or exclude "xyz" , a little harder solution is of course to play with regex: starts with abc (^abc). What ever suits you better

0

If you want to use a single Property to track both, you could create two different Views and apply a single predefined filter to each View, to only include traffic to the applicable hostname.
eg View for abc.example
Filter type - Predefined Include Only traffic to the hostname that are equal to
abc.example

rinse and repeat for the 2nd View, using the applicable hostname for that view (xyz.example)

If you were to want to use different Properties for each, you would need to add a tracking code snippet configured for a multitracker setup

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=GA_TRACKING_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'GA_TRACKING_ID');
gtag('config', 'GA_TRACKING_ID_2');
</script>

and then create the above-mentioned filter for the Views in each Property, so as to restrict the data going to each Property's Views to only include data for the hostname applicable to the specific Property.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.