?
SolvedPrivate

google analytics 2 top level domains

Posted on 2014-09-03
3
Medium Priority
?
56 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
Suggested Courses

752 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