Event for addthis_button_facebook_like and addthis_button_linkedin_counter

josh13ninigi May 23, 2012 06:14PM EDT


I used the addthis pug in for my site but I want to get the event when the user clicks on the facebook and linkedin buttons, some months ago I use the normal buttons( addthis_button_facebook) and the vents works but when I change to counters buttons, the events not works, and I need this events for internal statistics, I can help me or givme some ideas how I can make this my code is ( note: the Twteet works but facebbok and linkedin not):

<div class="addthis_toolbox addthis_default_style ">
<a class="addthis_button_facebook_like" ></a>
<a class="addthis_button_tweet"></a>
<a class="addthis_button_linkedin_counter"></a>
</div>

<script type="text/javascript">var addthis_config = {"data_track_addressbar":true};</script>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4eb1d8bd611956b2"></script>


<script language="javascript" type="text/javascript">
// Alert a message when the user shares somewhere
function eventHandler(evt) {

switch (evt.type) {
case "addthis.menu.open":
console.log('menu opened; surface=' + evt.data.pane);
break;
case "addthis.menu.close":
console.log('menu closed; surface=' + evt.data.pane);
break;
case "addthis.menu.share":
console.log('user shared to ' + evt.data.service);
break;
default:
console.log('received an unexpected event', evt);
}

if (evt.type == 'addthis.menu.share') {
alert('s');
var typess = evt.data.service;
alert(typess);
if (typess == 'facebook') {
try {
alert('facebook');
} catch (ex) {
//alert(ex);
}
}
if (typess == 'facebook') {
alert('twitter');
}
if (typess == 'tweet') {
alert('twitter');
}
}
if (evt.type == 'addthis.menu.open') {
alert('s1');
}
}




// Listen to various events
addthis.addEventListener('addthis.menu.open', eventHandler);
addthis.addEventListener('addthis.menu.close', eventHandler);
addthis.addEventListener('addthis.menu.share', eventHandler);


</script>

This question is closed to new answers.

Still need help?


General Topics

 

Developers