1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Tracking Multiple Domains with Google Analytics

Discussion in 'Google Analytics' started by Nups, Jul 3, 2008.

  1. #1
    Hi Guys,

    I want to add GA tracking code across 2 domains. Here is how the visitors travel from domain abc.com to xyz.com

    Step 1: abc.com/page1

    Step 2: abc.com/page2

    Step 3: xyz.com/page1


    As per Google 's Help Section, I am supposed to add the following code (with 2 extra lines in bold) on all the pages of both the domains.

    <script type="text/javascript">
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    </script>
    <script type="text/javascript">
    var pageTracker = _gat._getTracker("UA-xxxxx-x");
    pageTracker._setDomainName("none");
    pageTracker._setAllowLinker(true);
    pageTracker._initData();
    pageTracker._trackPageview();
    </script>

    It then instructs to add the _link function to any links between the domains AND instructs to add analytics tracking code and calls to _gat._getTracker and _initData on the page above the call to _link.

    So I have added the entire GA tracking code above the link pointing to xyz.com domain (see example below).

    <script type="text/javascript">
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    </script>
    <script type="text/javascript">
    var pageTracker = _gat._getTracker("UA-xxxxx-x");
    pageTracker._setDomainName("none");
    pageTracker._setAllowLinker(true);
    pageTracker._initData();
    pageTracker._trackPageview();
    </script>
    <a href="xyz.com/page1" onclick="pageTracker._link(this.href); return false;">

    My question is - Is this right? OR do I need to add the complete tracking code again at the bottom of the page just before </body> tag.

    Please give me your suggestions on how to get this done.
     
    Nups, Jul 3, 2008 IP
  2. gostats

    gostats Peon

    Messages:
    325
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    That looks ok. You should just try it and see if you have any troubles.
     
    gostats, Jul 4, 2008 IP