Why to use a piece of code to prevent multiple server calls in iframe tracking

Avatar

Avatar

sundhara_m

Avatar

sundhara_m

sundhara_m

09-08-2018

Hi Team,

I am currently using the below piece of code which was provided by Adobe to prevent multiple server calls in iframe tracking,

var isInIframe = (parent !== window)
if(isInIframe ){
return false;
}else{
return true;
}

Can anyone explain me that how this code is preventing the duplication of server call?

Thanks in Advance!

Sundhara Vadivu M.

Accepted Solutions (0)

Answers (1)

Answers (1)

Avatar

Avatar

StewSchilling

MVP

Avatar

StewSchilling

MVP

StewSchilling
MVP

12-08-2018

By "Server Call", I assume that you are referring to Adobe Analytics beacons.

This code tests to see if it is running within an iframe.  It could be shortened a bit as such:

if (parent !== window) {

    //we are in an iframe

     return false;

} else {

     //we are NOT in an iframe

     return true;

}

This code alone does nothing but return a boolean value (true or false).   I can think of a couple places where this code _could_ go within DTM to suppress a server call (Adobe Analytics beacon).

1) If this code were placed in a DTM custom condition, it would keep the rule from firing if DTM has been loaded in an iFrame.

2) If this code were placed in the AA custom code section of a DTM rule, it would keep the beacon from being sent if DTM has been loaded in an iFrame.  Note that within the AA custom code section of a DTM rule, returning false has the same effect as setting s.abort=true.

Where do you have this code implemented?

-Stew