javascriptadobeanalyticsadobe-analyticsweb-analytics

How to Exclude Higher Numeric Custom Events from Direct Call Rule


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 using the custom code below in Adobe DTM's direct call rule to set the pageload time 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 time 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 it to event 2.

Appreciate your help.


Solution

  • You can wrap it in a condition..

    var hpelement= +_satellite.getVar("hpelement");
    if (hpelement<=10000) {
        s.events= "event2";
        s.products=";;;;event2="+hpelement;
        s.linkTrackVars="events";
        s.linkTrackEvents="event2";
    }