kriskbx / whatsapp-sharing

whatsapp sharing button + generator

Home Page:http://kriskbx.github.io/whatsapp-sharing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to add Event Tracking or SocialTracking?

tordans opened this issue · comments

How can I add Google Analytics Event Tracking – or even better Social Tracking https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingSocial – to the Link/iFrame?

I want to know how many user click the button.
And maybe also, how many "see" the button (as in "button is rendered on page").

Are there any callbacks that I can use?

OK, I found it out: I can just add my on onclick events to the provided example link and those attributes will be included in the iFrame-Share-Link as well.

HOWEVER: You need to call the _gaq in the parent frame.
Example:

onclick="
  parent._gaq.push(['_trackSocial', 'whatsapp', 'share', YourUrl]); 
  parent._gaq.push(['_trackEvent', 'social_sharing', 'whatsapp', YourIdentifier]);"

Great!