septerr
septerr

Reputation: 6593

Google Analytics - _trackSocial event

I am not sure whether my code is incorrect or if I am not looking at the right place on the GA dashboard.

I have included the GA script in the head section.

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
        (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
            m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

    ga('create', '<%= Settings.google_id%>', 'healthfundit.com');
    ga('send', 'pageview');

On page load I am setting the account (don't know if this is needed):

$(function(){
      _gaq.push(['_setAccount', '<%= Settings.google_id%>']);
  });

And I am calling the _gaq.push when a Tweet action is fired (from debugging, I know this line of code is getting executed):

_gaq.push(['_trackSocial','Twitter', 'Tweet', '', '']);

But I can't find the info about this tweet anywhere on the GA dashboard.

UPDATE I have changed the code to:

ga('send', 'social', 'Twitter', 'Checkout Tweet', 'healthfundit.com', 
{'hitCallback': function(){alert('analytics.js done sending data');}});

And after tweeting, the callback function is getting called and displaying the alert message. But I just don't see anything on the GA dashboard about this event.

2nd UPDATE Like Blexy said in comment below, to see the info in GA you have to go to Acquisition > Plugins and select the Social Source and Action as your Primary Dimension. And this is very important: The info does not appear on the dashboard instantly. It seems to take about a day for the info to appear in GA.

Upvotes: 0

Views: 276

Answers (1)

Nick Blexrud
Nick Blexrud

Reputation: 9603

You're attempting to use the old (ga.js) social tracking code with the new Universal Analytics (analytics.js) base code.

Try using the Universal Analytics social interaction tracking code instead:

ga('send', 'social', 'Twitter', 'Tweet', 'http://targeturl.com');

Upvotes: 1

Related Questions