magento-hackathon / UniversalGaConversionTracking

15 stars 15 forks source link

Add Social Interactions tracking #9

Open peterjaap opened 10 years ago

peterjaap commented 10 years ago

Facebook;

FB.Event.subscribe('edge.create', function(targetUrl) {
    ga('send', {
        'hitType': 'social',
        'socialNetwork': 'facebook',
        'socialAction': 'like',
        'socialTarget': 'http://mycoolpage.com',
        'page': document.location.href
    });
});
peterjaap commented 10 years ago

Twitter;

twttr.events.bind('follow', function(event) {
    console.log(event);
    var followed_user_id = event.data.user_id;
    var followed_screen_name = event.data.screen_name;
    ga('send', {
        'hitType': 'social',
        'socialNetwork': 'twitter',
        'socialAction': 'follow', // maybe this is found in the event var as well? In order to make this function more generic
        'socialTarget': 'http://mycoolpage.com',
        'page': document.location.href
    });
});

Other actions; tweet, retweet, favorite, unfollow

peterjaap commented 10 years ago

Pinterest;

Event.observe('a[data-pin-log="button_pinit"]', 'click', function(event) { 
        ga('send', {
            'hitType': 'social',
            'socialNetwork': 'pinterest',
            'socialAction':'pin',
            'socialTarget': 'http://mycoolpage.com',
            'page': document.location.href
        });
    });

Other actions; repin (repin), embed_pin_text (follow)