There are some well written instructions on GTM social tracking by Simo Ahava here & the official Google dataLayer names for social here.

In order to track Like & Tweet buttons on the blog and item pages GA measurements need to be triggered, for example: [‘_trackSocial’, network, socialAction, opt_target, opt_pagePath]

image093

In order to track these social interactions the buttons just add customHTML triggered on gtm.dom ready

 

Facebook (JavaScript version)

<script>

FB.Event.subscribe(“edge.create”, function(targetUrl) {

dataLayer.push({

‘event’: ‘social’

‘network’: ‘facebook’,

‘socialAction’: ‘like’,

‘opt_target’: targetUrl, // optional

‘opt_pagePath’: window.location.pathname + window.location.search, // optional

‘eventValue’: parseInt(0.00)

});

});

</script>

 

Twitter (JavaScript version)

<script>

function trackTwitter(intent_event) {    if (intent_event) {      var opt_pagePath;      if (intent_event.target && intent_event.target.nodeName == “IFRAME”) {            opt_target = extractParamFromUri(intent_event.target.src, “url”);      } 

dataLayer.push({

‘event’: ‘social’,

‘network’: ‘twitter’,

‘socialAction’: ‘tweet’,

‘opt_target’: opt_target, // optional

‘opt_pagePath’: opt_pagePath, // optional

‘eventValue’: parseInt(0.00)

});

} } //Wrap event bindings – Wait for async js to load  twttr.ready(function(twttr){   //event bindings    twttr.events.bind(“tweet”, trackTwitter); });

</script>

 

Google+ (For Universal this is NOT needed for Legacy GA.js)

<script>

function sendPlus(targetUrl) {

dataLayer.push({

‘event’: ‘social’,

‘network’: ‘google’,

‘socialAction’: ‘+1’,

‘opt_target’: targetUrl.href, // optional

‘opt_pagePath’: window.location.pathname + window.location.search, // optional

‘eventValue’: parseInt(0.00)

});

};

</script>

 

See this Google documentation for details of the Facebook and Twitter API.

https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingSocial#facebook

https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingSocial#twitter

 

Facebook (Static Link version)

<a href=”http://www.facebook.com/ClientDomain” target=”_blank”>

<img src=”/images/social_network/icon_facebook.jpg”>

</a>

 

Hardcoded onclick code can be added…

<a href=”http://www.facebook.com/ClientDomain” target=”_blank” onclick=”dataLayer.push({‘event’:’social’, ‘network’:’facebook’, ‘socialAction’: ‘like’, ‘opt_target’:window.location.href, ‘opt_pagePath’:window.location.pathname+window.location.search, ‘eventValue’:parseInt(0.00)});”>

<img src=”/images/social_network/icon_facebook.jpg”>

</a>

 

image094

For Pinterest see this help page:

http://www.lunametrics.com/blog/2012/03/12/tracking-pinterest-event-tracking/

 

image095

Please note: for ShareThis no action is needed as this can be added via GTM for GA classic:

<!– SOURCE: support.sharethis.com/customer/portal/articles/446390-google-analytics –>

<script type=”text/javascript”>

var __st_loadLate = true; // Wait for dom.content ready before loading widget

</script>

 

<!– SSL shareThis version – default version is //w.sharethis.com –>

<script src=”//ws.sharethis.com/button/buttons.js” type=”text/javascript”>

</script>

 

<script type=”text/javascript”>

if(typeof(stLight)===”undefined”){

stLight={}

};

stLight.options({

“publisherGA”: “{{settings_ga_id}}”,

“tracking”: “true”,

“event”: “sharethis_tracker_loaded”

});

</script>

 

image096

Please note: for AddThis no action is needed as this can be added via GTM in GA classic using:

 <scripttype=”text/javascript”> var addthis_config={         “data_ga_property”:”{{settings_ga_id}}”,        “data_ga_social”: true,        “event”: “addthis_tracker_loaded”  };</script>

Help page:

http://support.addthis.com/customer/portal/articles/381260-google-analytics-integration#how

 

image096For AddThis GA universal – you can use bind to ID=”addthis_button_preferred_[n]”. See the example here.

image097

<!– AddThis Script to bind onclick GTM social event based on ID present on the page –>

 

<script type=”text/javascript”>

window.dataLayer = window.dataLayer || [];

 

// FACEBOOK

document.getElementById(“addthis_button_preferred_1“).onclick = function(){

window.dataLayer.push({

‘event’: ‘social’,

‘network’: ‘Facebook’,

‘socialAction’: ‘like’,

‘opt_target’: document.getElementById(“addthis_button_preferred_1”).href,

// ‘opt_pagePath’: opt_pagePath, // optional

‘eventValue’: 0,

‘socialButtonPosition’: ‘top’

});

};

 

// TWITTER

document.getElementById(“addthis_button_preferred_2“).onclick = function(){

window.dataLayer.push({

‘event’: ‘social’,

‘network’: ‘Twitter’,

‘socialAction’: ‘tweet’,

‘opt_target’: document.getElementById(“addthis_button_preferred_2”).href,

// ‘opt_pagePath’: opt_pagePath, // optional

‘eventValue’: 0,

‘socialButtonPosition’: ‘top’

});

};

 

// GOOGLE PLUS

document.getElementById(“addthis_button_preferred_3“).onclick = function(){

window.dataLayer.push({

‘event’: ‘social’,

‘network’: ‘Google+’, // Changed from ‘google’

‘socialAction’: ‘+1’,

‘opt_target’: document.getElementById(“addthis_button_preferred_3”).href,

// ‘opt_pagePath’: opt_pagePath, // optional

‘eventValue’: 0,

‘socialButtonPosition’: ‘top’

});

};

</script>

 

0117 3361103