google-analyticsusage-statisticsvisitor-statistic

Track user activity from different domains (but same site) with google analytics


I've got a site that has many domains and subdomains. They all go to the same pages and do the same stuff. The only thing that changes from domain to domain is the images and colors of the site. So I wanna track the users activity and started using google analytics. I changed the google script to this:

<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-XXXXX-X', 'auto', {'allowLinker': true});
      ga('require', 'linker');
      ga('linker:autoLink', ['domain2.com'] );
      ga('send', 'pageview');

</script>

But this only gives me the data from all activities in the browser no matter from which domain it came. I wanna know if it's possible to also separate which domain had more hits and stuff like that. Is it possible? Is there any other tool where this is possible?

Thanks :)


Solution

  • Sounds like you are tracking all (and any) of your domains with that code snippet you provided. Some best practices are to

    1. set up a view for each domain (with the appropriate Include filter applied) and also
    2. set up a Roll-up view that contains data for all your domains, and you would definitely need an Prepend hostname filter so you can see which domain traffic comes in from.
    3. set up a Raw view that is completely unfiltered,
    4. and finally set up a Test view for testing out new configurations.

    Edit: Here's a screenshot of how you would include a filter for a specific domain:

    enter image description here