문제

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');    
}
도움이 되었습니까?

해결책

  • 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');    
}

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top