Expand my Community achievements bar.

SOLVED

DTM Direct Call Rule - Don't Set High Integer values to Custom Events

Avatar

Level 2

Hello,

We recently implemented a script on our site to capture the time it takes to render an above-the-fold element on our homepage (doing this to measure perceived page load).

We are currently using the custom code below in Adobe DTM's direct call rule to set the time (integer with two decimals) to a numeric custom event. Event2 would be the numeric custom event we want the time value to set to and hpelement would be the data element that retrieves the value from the deployed data layer.

s.events= "event2";
s.products=";;;;event2= "+_satellite.getVar("hpelement")+""
s.linkTrackVars="events";
s.linkTrackEvents="event2";

The above setup seems to work out fine except for a couple of instances when the time (in seconds) is set to an insanely high number (e.g. 5 million seconds vs. 4 seconds). When I look at the data in Adobe Analytics, these high numbers seem to be reporting from bot-related traffic (e.g. IP addresses from Google).

My question would be if there's anything I can change in the custom code above that can exclude those high numbers from being set to event2. For example, if the data element has a value of above 10000 then do not set to custom event2.

Appreciate your help.

1 Accepted Solution

Avatar

Correct answer by
Level 9

You also asked this question on Stack Overflow, and you marked my answer as solved, but I may as well post it here too, for posterity.

btripple's answer is basically right in principle, but the condition itself isn't what you are looking for.  His condition will return true if the returned data element value is truthy, which is basically any number except zero.

Here is what you are looking for:

var hpelement= +_satellite.getVar("hpelement");

if (hpelement<=10000) {

    s.events= "event2";

    s.products=";;;;event2="+hpelement;

    s.linkTrackVars="events";

    s.linkTrackEvents="event2";

}

View solution in original post

3 Replies

Avatar

Level 4

Hi there, you should simply not append event2 to the products variable if it exceeds said number or exclude from your reporting.

On another note, is the above the fold element a product, I was wondering why you decided to use the products variable if it isn't product related?

Avatar

Level 3

It is simple as adding custom logic:

if(criteria is met){

s.products=";;;;event2= "+_satellite.getVar("hpelement")+""

}

so this might work

if(_satellite.getVar("hpelement")){

s.events= "event2";
s.products=";;;;event2= "+_satellite.getVar("hpelement")+""
  s.linkTrackVars="events";
  s.linkTrackEvents="event2";

}else{

  // do nothing

}

Avatar

Correct answer by
Level 9

You also asked this question on Stack Overflow, and you marked my answer as solved, but I may as well post it here too, for posterity.

btripple's answer is basically right in principle, but the condition itself isn't what you are looking for.  His condition will return true if the returned data element value is truthy, which is basically any number except zero.

Here is what you are looking for:

var hpelement= +_satellite.getVar("hpelement");

if (hpelement<=10000) {

    s.events= "event2";

    s.products=";;;;event2="+hpelement;

    s.linkTrackVars="events";

    s.linkTrackEvents="event2";

}