SolvedPrivate

google analytics 2 top level domains

Posted on 2014-09-03
3
30 Views
Last Modified: 2016-02-24
Hello,
I have inherited a website that uses the same HTML code base for two top level domains for example www.domain123z.com and www.domain456z.com.

I would like to record visitor sessions into separate properties in google analytics. So I will know X amount of visitors used domain123z.com and X amount of visitors used domain456z.com

Is this possible in google analytics?  I am using ga.async what would my tracking look like?

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-123456-1']);
  _gaq.push(['_setDomainName', 'domain123z.com']);
  _gaq.push(['_setAllowLinker', true]);
  _gaq.push(['_trackPageview']);

  _gaq.push(['_setAccount', 'UA-123456-2']);
  _gaq.push(['_setDomainName', 'domain456z.com']);
  _gaq.push(['_setAllowLinker', true]);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>

Open in new window


Thank You.
0
Comment
Question by:jay_eire
  • 2
3 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40302377
what about :

<script type="text/javascript">

  var _gaq = _gaq || [];

if(location.host.match(/\.?([^.]*)\.com/).pop() == "domain123z") {

  _gaq.push(['_setAccount', 'UA-123456-1']);
  _gaq.push(['_setDomainName', 'domain123z.com']);
  _gaq.push(['_setAllowLinker', true]);
  _gaq.push(['_trackPageview']);
}
else {
  _gaq.push(['_setAccount', 'UA-123456-2']);
  _gaq.push(['_setDomainName', 'domain456z.com']);
  _gaq.push(['_setAllowLinker', true]);
  _gaq.push(['_trackPageview']);
}
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>

Open in new window

0
 
LVL 7

Author Comment

by:jay_eire
ID: 40307873
thank you for reply I will check this out.
0
 
LVL 82

Expert Comment

by:leakim971
ID: 40308135
np
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Marketing can be an uncomfortable undertaking, especially if your material is technology based. Luckily, we’ve compiled some simple and (relatively) painless tips to put an end to your trepidation and start your path to success.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now