1 Reply Latest reply on Aug 12, 2018 2:26 PM by stewarts16448458

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

    sundhara m

      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. Re: Why to use a piece of code to prevent multiple server calls in iframe tracking
          stewarts16448458 Level 4

          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

          2 people found this helpful