1 website, 2 domains > so 2 tracking codes?

Discussion in 'Google Analytics' started by jacoberoi, May 27, 2010.

  1. #1
    Hi

    I've been struggling with a site having 2 domain extensions (parked domain: .com and .co.za) for a while now. I wonder if the analytics on the site is tracking traffic from only 1 of the domains, so I tested it.

    I created 2 analytics tracking codes and added both to that 1 page. I see different stats for the same page, accessed from .com and .co.za domain. Is that possible?

    The owner doesn't want to spend money hosting the .com, just to redirect it to the .co.za. I've posted a thread earlier on the .htaccess issues, while looking for a solution.

    Any help much appreciated.
     
    jacoberoi, May 27, 2010 IP
  2. magda

    magda Notable Member

    Messages:
    5,197
    Likes Received:
    315
    Best Answers:
    0
    Trophy Points:
    280
    #2
    Having 2 codes on one page just means all your data is doubled. It's pointless, messy and you can't believe any of the metrics.
     
    magda, May 27, 2010 IP
  3. jacoberoi

    jacoberoi Peon

    Messages:
    32
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for your reply Magda. But how would you explain the fact that there is different data for the same period?
    Even though the data trends are very similar, it's not an exact match (10% difference)?
     
    jacoberoi, May 27, 2010 IP
  4. trevHCS

    trevHCS Peon

    Messages:
    40
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Putting 2 lots of analytics codes onto the site is likely to produce some odd results since it's being run twice and potentially the user will be getting counted twice. It gets a little more complicated as things like moving between pages relies mostly on cookies which are usually domain dependent. In essence anyone going to more than one page will screwup the stats slightly although the fact that they're only 10% diff suggests that most people are only ever landing on one page.

    It is possible to track more than one domain now with the new analytics code although it's a little complicated and just redirecting would be a better solution.

    Edit: Replied to your htaccess one too, although not 100% sure it'll work.

    Trev
     
    Last edited: May 28, 2010
    trevHCS, May 28, 2010 IP
  5. josephwaldman1984

    josephwaldman1984 Peon

    Messages:
    306
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    well you have to make a little bit change in .htaccess file and than all set :) redirect that site to the other one :)

    RewriteCond %{HTTP_HOST} ^(www.)?mysite\.com [NC]
    RewriteRule (.*) http://www.mysite.co.za/$1 [R=301,L]


    here you go :)
     
    josephwaldman1984, May 28, 2010 IP
  6. khongwir

    khongwir Peon

    Messages:
    266
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Delete the repeated code and wait for 2 days or so. Check the results then. It should give accurate results.
    As joseph mentioned, a change in .htaccess would also solve your redirect issues. It requires a little bit of coding and an access permission from your hosting provider.
     
    khongwir, May 29, 2010 IP
  7. jacoberoi

    jacoberoi Peon

    Messages:
    32
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Thanks Trev. I agree that it produces skewed results. But if I have to drop a tracking code, I don't know which one. .co.za is the target market but .com has higher volume.
    It's actually interesting how "different" keywords, referrers and so show up for the different domains.
     
    jacoberoi, May 31, 2010 IP
  8. jacoberoi

    jacoberoi Peon

    Messages:
    32
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Thanks Joseph. However the code doesn't redirect .com to .co.za.
    Any further ideas we can try?
     
    jacoberoi, May 31, 2010 IP
  9. jacoberoi

    jacoberoi Peon

    Messages:
    32
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Thanks for the suggestion. Don't know which one to drop (see other post).
    .htaccess as shown above doesn't redirect the .com to the .co.za.
     
    jacoberoi, May 31, 2010 IP
  10. trevHCS

    trevHCS Peon

    Messages:
    40
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Right, back after weekend and bank holidays. In terms of what to drop, once you get the redirect working then I'd drop the .com tracking code and make sure the other one is set specifically for the .co.za domain.

    Alternatively, if you switch to the new code you can track either one depending on the domain name the person lands on. This is based on the newer Google code. But unless you've got different content per domain then the redirect when it works would still be the best option.

    
    
    // *** SET THESE *** // 
    
    var ga_account_id_1     = 'UA-XXXXXX-YY';      // Analytics account ID for .co.za
    var ga_account_id_2     = 'UA-XXXXXX-YY';      // Analytics account ID for .com
    var ga_account_dom_1 = 'DOMAIN_NAME1';    // Eg: mydomain.co.za
    var ga_account_dom_2 = 'DOMAIN_NAME2';    // Eg: mydomain.com
    
    // *** END OF CHANGES ** //
    
    
    if (document.domain == ga_account_dom_1) { 
      var ga_account_id_sel      = ga_account_id_1;
      var ga_account_dom_sel  = ga_account_dom_1;
    }
    if (document.domain == ga_account_dom_2) { 
      var ga_account_id_sel      = ga_account_id_2;
      var ga_account_dom_sel  = ga_account_dom_2;
    }
    else { 
      var ga_account_id_sel     = '';  
      var ga_account_dom_sel  = '';
    }
    
    
    var _gaq = _gaq || [];
    
    _gaq.push(['_setAccount', ga_account_id_sel]); 
    _gaq.push(['_setDomainName', ga_account_dom_sel]);
    _gaq.push(['_setAllowLinker', true]);
    _gaq.push(['_setAllowHash',   false]);
    _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);
      })();
    
    
    Code (markup):
    Will reply to the .htaccess thing in that thread to keep things logical.

    Trev
     
    trevHCS, Jun 1, 2010 IP