Question

I have a function that tracks custom events. I would like to set s.channel in the function, but so far no success. It seems that s.channel is set through onload only? Is it possible to capture s.channel in the onClick function?

Here is my sample code.

function customLinks() {
    s.channel='CHANNEL VALUE'; //<=== this is not working
    s.events = 'events27';
    s.linkTrackVars = 'events, event27';
    s.linkTrackEvents = 'event27';
    s.tl(this.'o','Custom Link Click');    
}
Was it helpful?

Solution

  • In order to track a variable/event in an s.tl call, you need to declare them in linkTrackVars and linkTrackEvents. The only exception is pageName, which will get tracked whether or not you declare it.
  • linkTrackEvents is a comma delimited list of any events you want to track (note: you should not have spaces between the commas). linkTrackVars is a comma delimited list of variables you want to track. For example, you can see in your own code how you are tracking event27. Note that for events, you must declare events in linkTrackVars (which you did).
  • In your s.events you have "events27" when it should be "event27" (no "s").
  • Also, in your s.tl call pass this, 'o'
  • You don't need to put event27 in linkTrackVars, only linkTrackEvents

So overall, this is what your function should look like:

function customLinks() {
    s.channel='CHANNEL VALUE'; //<=== this is not working
    s.events = 'event27';
    s.linkTrackVars = 'events,channel';
    s.linkTrackEvents = 'event27';
    s.tl(this,'o','Custom Link Click');    
}

OTHER TIPS

That won't be tracked using s.tl, I copy s.channel to an ever to work around that. Or, use a prop if you need pathing.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top