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.
  2. Better Analytics for WordPress Get It Free

Cross domain tracking with Google Analytics

Discussion in 'Google Analytics' started by newinseo, Feb 13, 2012.

  1. #1
    Hello,

    I would be glad if someone could help me with correct GA setting..

    I'v read Google's help, but something is wrong anyway..

    So i have site.com with seach form. GA code is following
    var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-XXX']);
      _gaq.push(['_setDomainName', '.site.com']);
      _gaq.push(['_setAllowLinker', false]);
      _gaq.push(['setAllowHash', false]);
      _gaq.push(['_trackPageview'])
    Code (markup):
    and this is a part of my form submit function
    if (valid) {
        _gaq.push(['_linkByPost', this]);
        $('#myform').submit();
    };
    Code (markup):
    The form sends a request to book.site.com with such GA
    var _gaq = _gaq || [];
                 
            aagGaq.addIndex('');
            _gaq.push(
            ['_setAccount', 'UA-XXX'],
            ['_setDomainName', 'none'], 
            ['_setAllowLinker', false],  
            ['_setAllowHash', false],   
            ['_setSessionCookieTimeout', 0],
            ['_setVisitorCookieTimeout', 0],
            
            ['_trackPageview'] 
            );
    Code (markup):
    Then user is redirected to checkout.com, where the goal is saved.

    Test results:
    If i go from some referral to shop.site.com and reach a goal my referral is shown correct. But if i start with site.com - referral is shown as shop.site.com or just site.com.

    So the error must me somewhere on the fist site.com page, but i don't know how to fix that.

    P.S. I have full acces only to site.com and other sites/domains are managed by the other IT team, so they set _setAllowLinker to false for some mysterious technical reasons. (Maybe because of the url lenght issues)
     
    newinseo, Feb 13, 2012 IP
  2. utahbc

    utahbc Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You may have figured this out already, but _setAllowHash() has been deprecated, and is no longer necessary for cross domain tracking. Also, -setAllowLink is set to false by default. It needs to be set to true for cross domain tracking (see the glossary linked to below under RESOURCES). You'll also need code on checkout.com.

    I believe your code should look like this for site.com, book.site.com and checkout.com:

    On site.com:

    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-XXX']);
    _gaq.push(['_setDomainName', '.site.com']);
    _gaq.push(['_setAllowLinker', true]);
    _gaq.push(['_addIgnoredRef', 'site.com']);
    _gaq.push(['_trackPageview'])




    On book.site.com

    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-XXX']);
    _gaq.push(['_setDomainName', '.site.com']);
    _gaq.push(['_setAllowLinker', true]);
    _gaq.push(['_addIgnoredRef', 'site.com']);
    _gaq.push(['_trackPageview'])


    On checkout.com:

    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-XXX']);
    _gaq.push(['_setDomainName', 'checkout.com']);
    _gaq.push(['_setAllowLinker', true]);
    _gaq.push(['_addIgnoredRef', 'site.com']);
    _gaq.push(['_trackPageview'])




    RESOURCES

    Glossary
    Use this to as you read the articles below to define tracking codes like _setAllowLink, _link, _linkByPost, etc.
    http://code.google.com/apis/analytics/docs/gaJS/gaJSApiDomainDirectory.html

    1) Very helpful - explains a similar scenario to yours with a domain, subdomain, and a separate (or 3rd party, e.g., shopping cart) domain:
    http://code.google.com/apis/analytics/docs/tracking/gaTrackingSite.html#multipleDomains

    2) This third party (non-Google) article explains how to prevent site.com and shop.site.com as showing up as the referral when you start from site.com. (Note it was written prior to _setAllowHash()'s deprecation.):
    http://www.roirevolution.com/blog/2011/01/google_analytics_subdomain_tracking.php

    3) This article explains how having to label all your links and forms that drive to other domains with _link() and _linkByPost() respectively can get cumbersome, especially for large sites. He offers an automated solution.
    http://www.tatvic.com/blog/google-analytics-cross-domain-tracking/
     
    utahbc, Mar 9, 2012 IP