Expand my Community achievements bar.

SOLVED

How do I track social share icons in one custom script?

Avatar

Level 3

Hi, 

I am trying to track my social share icons in a custom script.. I have managed to captured the name of each of the icon clicked on but how do I set it to track to different events.

I have events 8,9,10 set up in my Event based rule but need to add a custom script to e.g. set my Facebook Like to event8 and Tweet to event 9 and Pint it to event 10. I didn't want to setup separate event rules for this and thought there will be a way to track each icon to different events using 1 EBR

i tried using if (s.event8) {
s.linkTrackVars=s.LinkTrackEvents="_satellite.setVar('shareType',shareType[0].innerHTML),event8"
s.addEvent('event8')
console.log(s.events); 

but it doesn't seem to be working.. I just want to make sure that my FB Like is tracked to event 8, Tweets to event9  etc, instead of having all tracked to all the events set up in my EBR.

Help!

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi Kee , 

Since you have managed to captured the name of each of the icon clicked on,  So you can basically add an if else logic to custom code in Adobe Analytics Section in a Event based rule like below:-

var socialname= $(this).attr('LinkName');// write your own logic to capture link name if(socialname.search("facebook")!=-1) { s.linkTrackVars = 'prop7,events'; s.linkTrackEvents = 'event8'; s.events='event8'; s.prop7 = socialname; } if(socialname.search("twitter")!=-1) { s.linkTrackVars = 'prop7,events'; s.linkTrackEvents = 'event9'; s.events='event9'; s.prop7 = socialname; } if(socialname.search("Pintit")!=-1) { s.linkTrackVars = 'prop7,events'; s.linkTrackEvents = 'event10'; s.events='event10'; s.prop7 = socialname; }

Thanks & Regards

Parit Mittal

View solution in original post

3 Replies

Avatar

Correct answer by
Level 10

Hi Kee , 

Since you have managed to captured the name of each of the icon clicked on,  So you can basically add an if else logic to custom code in Adobe Analytics Section in a Event based rule like below:-

var socialname= $(this).attr('LinkName');// write your own logic to capture link name if(socialname.search("facebook")!=-1) { s.linkTrackVars = 'prop7,events'; s.linkTrackEvents = 'event8'; s.events='event8'; s.prop7 = socialname; } if(socialname.search("twitter")!=-1) { s.linkTrackVars = 'prop7,events'; s.linkTrackEvents = 'event9'; s.events='event9'; s.prop7 = socialname; } if(socialname.search("Pintit")!=-1) { s.linkTrackVars = 'prop7,events'; s.linkTrackEvents = 'event10'; s.events='event10'; s.prop7 = socialname; }

Thanks & Regards

Parit Mittal

Avatar

Level 3

Thanks Parit, trying this out now.

This is a snippet of my logic for capturing the link name... 

var clickClass = this.getAttribute("class").toLowerCase();
var clickName = this.innerHTML;

if (clickClass.indexOf("facebookbutton") > -1) {
  _satellite.setVar('shareType', "facebook");
  _satellite.setVar('shareValue', clickName);
  console.log("YAY!", "facebook");
  return true;

etc another one for twitter and pinterest.

I know there is any easier way of writing this.

Avatar

Level 3

HI Parit,

Can you help with capturing the linkname logic tplease, my  (clickClass.indexOf("facebookbutton")  seems to be errorring out now