Analytics event tracking on subdomain

Discussion in 'Web Development and Programming' started by valdet, Nov 4, 2013.

  1. valdet

    valdet Regular Member

    Joined:
    Oct 18, 2013
    Messages:
    22
    Likes Received:
    13
    Location:
    Kosovo
    I'm having an issue with events NOT being tracked on GAnalytics on my subdomains.

    I recently added a subdomain and while the standard reporting is properly recorded, the Custom Events are not recorded at all.

    I'm specifically looking to record clicks and form submissions through onClick and onSubmit js events

    My GA code
    Code:
    <script type="text/javascript">
    
    
      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-XXXXXXX-X']);
      _gaq.push(['_setDomainName', 'mysite.com']);
      _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>
    and here are my implementations in source

    onClick:
    Code:
    <a onClick="_gaq.push(['_trackEvent','Some Page Click Tracking','http://sub.mysite.com/somepage.html','Click']);" href="http://sub.mysite.com/somepage.html">Some Page</a>
    onSubmit:
    Code:
    <form onSubmit="_gaq.push(['_trackEvent','Some Page Form Tracking','http://sub.mysite.com/somepage.html','Submit']);" action="form.php" method="POST" target="_blank">
    Events are tracked just fine in my domain with same code, but this same code implementation does not record on subdomains.
     
  2. valdet

    valdet Regular Member

    Joined:
    Oct 18, 2013
    Messages:
    22
    Likes Received:
    13
    Location:
    Kosovo
    Bumping this thread. Hope someone can help.

    Basically my setup is:

    Code:
    http://sub.mysite.net <-- Content Pages
    http://www.mysite.net/forum/ <-- Forum
    I've asked in Analytics forum, but wasn't lucky with any help. Any suggestions ?

    I can share the URL in PM
     
    Last edited: Nov 26, 2013
  3. MyDigitalpoint

    MyDigitalpoint Regular Member

    Joined:
    Jun 5, 2013
    Messages:
    114
    Likes Received:
    30
    Location:
    Virtual World
    Sorry, I can help but say go for your own Analytics/stats software installed onto your site.

    I don't understand why people rely on third-service providers when there are scripts or software that can be installed on the same server and run more efficiently.
     
  4. valdet

    valdet Regular Member

    Joined:
    Oct 18, 2013
    Messages:
    22
    Likes Received:
    13
    Location:
    Kosovo
    Can you help if you have any tips regarding this situation. Thanks.

    I understand your point about using alternative stats software, but so far I have been very happy with all the insight I get from using it.
     
  5. JoeyJ

    JoeyJ Regular Member

    Joined:
    Nov 29, 2013
    Messages:
    18
    Likes Received:
    10
    I'm not sure completely but you might need to add the href/form data BEFORE you call _trackEvent. I'm not positive but this could be causing the issue. The function is usually called after.

    ex.
    <a href="#" onClick="_gaq.push(['_trackEvent', 'Videos', 'Play', 'Baby\'s First Birthday']);">Play</a>
     
  6. valdet

    valdet Regular Member

    Joined:
    Oct 18, 2013
    Messages:
    22
    Likes Received:
    13
    Location:
    Kosovo
    Thanks for reply @JoeyJ

    Unfortunately that does not work either
     

Share This Page