0

We own one single domain where we host several customers. Example:

  • domain.com (our welcome and registration site)

  • domain.com/customer1 (1st customer)

  • domain.com/customer2 (2nd customer)

  • domain.com/customer3 (3rd customer)

Is it possible to have multiple Google Analytics accounts, so that the analytics are targeted depending on the url?

  • domain.com (our own GA code)

  • domain.com/customer1/* (1st customer's GA code)

  • domain.com/customer2/* (2nd customer's GA code)

  • domain.com/customer3/* (3rd customer's GA code)

Any ideas? Thanks!

  • There is no restriction on this from Google Analytics, but whether you can do it is going to depend on how you are including GA tracking on your site. Do you use GTM? – Reve May 21 at 13:51
  • @Reve i use gtag, but i dont see any examples on how to add more ids, unless I just repeat the js include. – Andres SK May 22 at 15:27
1

absolutely. It is even possible:

  • domain.com (our own GA code)
  • domain.com/customer1/* (our own GA code, 1st customer's GA code)
  • domain.com/customer2/* (our own GA code, 2nd customer's GA code)
  • domain.com/customer3/* (our own GA code, 3rd customer's GA code, GA code of an affiliate of 3rd customer)

You don't said in your question, that you use GTM instead of GA. With GA you can easily add multiple IDs, like here

<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-12345-12', 'auto'); 
ga('create', 'UA-1244524-22';, 'auto',{'name': 'WebProperty2'}); 
ga('send', 'pageview');
ga('WebProperty2.send', 'pageview');
</script>

But with GTM you can indeed add multiple GTM containers, but not multiple dataLayers, as noted here.

  • Is there any way to send the analytics info to different ids with the same included js? Example of one id: <script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXXX-X"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-XXXXXXXXX-X'); </script> – Andres SK May 22 at 15:29
  • i updated my answer – Evgeniy May 22 at 15:54
  • I can definitely switch to GA, but in your example i only see 1 setAccount value, to add a second one should I just add a new push call with the other account id ? – Andres SK May 22 at 18:03

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.