Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

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

sundhara_m
Level 2
Level 2

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.

1 Accepted Solution
StewSchilling
Correct answer by
Community Advisor
Community Advisor

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

View solution in original post

1 Reply
StewSchilling
Correct answer by
Community Advisor
Community Advisor

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

View solution in original post