Vous êtes sur la page 1sur 9

DTM

USE CASEs

Table of Contents

Contents Page no
Time out in DTM 3
setInterval() 4
Use Cases
DTM rules load order 6

_satellite.pageBottom() and its 7


application
Multiple Page load rules 8
DTM - Target use case 9

1. Time out in DTM:


Lets consider a situation where there is a variable, say eVar1
which grabs value from a specific data layer element. For e.g. the
data layer dtm_digitalData and the element is guestID.
eVar1 = dtm_digitalData.guestID;
Now this data layer element sometimes take more time to get
populated and sometimes it take less, depending on the backend
processing and the availability of the data.
Now there can be scenario where the data layer element may not
be available by the time the control reaches the code and hence
eVar1 will report none/unspecified values in the reports.
How to get rid of such situation? The answer is using Time out
There are two ways to make your code to wait or run at specified
time interval. These two key methods are:
1. setTimeout(function, milliseconds)
Executes a function, after waiting a specified number of
milliseconds.
2. setInterval(function, milliseconds)
Same as setTimeout(), but repeats the execution of the
function continuously.
In most of the cases setInterval() is better than setTimeout()
because setInterval keeps on executing again and again. Once
you achieved the desired condition then you can stop its
execution by using a simple method known as clearInterval()

clearInterval(timerVariable)
Stops the executions of the function specified in the
setInterval() method.

setInterval() implementation:
Using setInterval() in combination with clearInterval() can really
help in tackling such situations. Here is the sample code
s.abort=true; //stopping the
default s.t()
var prodInterval = setInterval(prodWait, 100); //initiating
the setInterval
function prodWait() {
var temp=dtm_digitalData.guestID; //function which
repeats
if (temp) {
s.eVar1 = temp;
clearInterval(prodInterval); //stopping the
function
s.t();
}
}
In above piece of code, setInterval is using 100 milliseconds as a
ping time. This will keep checking the value of guestID after every
100 milliseconds. As soon as the value is available in temp
variable, the control will enter into the IF block and will
populated eVar1. Eventually clearInterval() function will also
get executed and will refrain setInterval from executing
furthermore.
s.abort=true stops default s.t() call from getting triggered.
The s.t() call gets triggered only when temp variable is
available and IF block gets executed.

Point to be note:
In above code snippet, s.t() is placed within IF block of
setInterval() function. Question arises here is that can we put
s.t() outside the function, after the setInterval() ?
The answer is simple no. There is a specific reason for this and
the reason is asynchronous nature of setInterval function. Yes,
setInterval runs asynchronously. When setInterval is called then
it starts running in parallel to the code written below. So if you
will put s.t() outside the function, image request will get fired
instantly and timeout logic would not work as desired.
If there are three critical pages say a, b and c on which you want
timeout to happen until the values from datalayer are available.
Then you would have to write three set interval functions for each
page and s.t() should be there within the functions only.
if (document.URL.indexOf(a.com") > -1){ // for
page a
s.abort=true;
var prodInterval = setInterval(prodWait, 100);
function prodWait(){
var temp=dtm_digitalData.productID;
if (temp){
s.products = temp;
clearInterval(prodInterval);
s.t();
}
}
}

if (document.URL.indexOf(b.com") > -1){ // for


page b
s.abort=true;
var prodInterval = setInterval(prodWait, 100);
function prodWait(){
var temp=dtm_digitalData.productID;
if (temp){
s.products = temp;
clearInterval(prodInterval);
s.t();
}
}
}

if (document.URL.indexOf(c.com") > -1){ // for


page c
s.abort=true;
var prodInterval = setInterval(prodWait, 100);
function prodWait(){
var temp=dtm_digitalData.productID;
if (temp){
s.products = temp;
clearInterval(prodInterval);
s.t();
}
}
}

2. Load order in DTM:


There has been lot of questions and confusion regarding the
exact load order of the DTM rules and their different blocks.
Though Adobe has a documentation regarding same but its not
very clear and proven.
For POC purpose, console.log() function has been used to check
the flow and determine the exact load order.

Top of the page rule get called


Top of the page rule Sequential JS block executed
Bottom of the page rule get called
Top of the page rule Non Sequential JS block
executed
Bottom of the page rule Sequential JS block executed
DOM ready rule get called
App measurement get called
Bottom of the page rule Adobe Analytics block
executed
DOM ready rule Adobe Analytics block executed
Top of the page rule Adobe Analytics block executed
Bottom of the page rule Non Sequential JS block
executed
DOM ready rule - Non Sequential JS block executed
DOM ready rule - Sequential JS block executed
OnLoad rule get called
OnLoad rule Non Sequential JS block executed
OnLoad rule Sequential JS block executed

Note Adobe Analytics block never get called/executed for onload


page load rules.
3. _satellite.pageBottom() and its application:
_satellite.pageBottom() call is a footer code snippet provided by
Adobe for DTM implementation. It is complimentary to the header
code and is recommended to be added at the end of the body
tag.

<script type="text/javascript">_satellite.pageBottom();</script>

_satellite.pageBottom() acts like a flag/checkpoint which helps to


control the execution of the page load rules.
While creating a page load rule, there are four conditions:
1. Top of the page
2. Bottom of the page
3. DOM ready
4. On load
When the control of the code reaches the _satellite.pageBottom(),
it triggers the page load rule which has condition as bottom of
the page.

Uses Cases
1. What happens if pageBottom call is missing from the
page code?
The answer is - rules will still fire. Why, because assets JS of
DTM has a default pageBottom call. So, in case, it is missing
from the page code, the logic with in the asset file which check
for it and then it will fire the pageBottom call itself.
The only benefit of having a pageBottom within the page code
is that you can control the execution of bottom of the page
load rules.

2. What happens when there are two pageBottom calls?


In such case, bottom of the page load rules will fire twice,
though image request will fire only once.
4. Multiple Page load rules:
In DTM, Page load rules never fire any image request but they
only set the variables. Once all the variables are set in all the
page load rules then Adobe Analytics library clubs all the data
and executes s.t() function which fire an image request.
But in event based rule you have functionality to fire the image
request from the rule only. You have option to choose s.t() and
s.tl() both.

Uses Case
1. What happens when there are more than one page load
rules firing together?
The answer is both rules will execute and will populate the
respective variables and then s.t() from the library will club the
variables from different rules together and fire a single image
request.
There is always a single Image request irrespective of number
of page load rules. As mentioned above, page load rules never
fire any image request themselves but they only set the
variables.
5. DTM Target Use case
There can be a situation where Adobe Target wants to personalize
the experience for the users who done certain activity and you want
to do that on the basis of cookies.
For e.g. you want to target visitors who would abandon the journey
while in the booking flow and in the subsequent visit they do a
purchase.
Solution In such situation a cookie can be dropped for every user
while they are in the booking journey. This cookie also have the visit
number.
If this user reaches the booking confirmation page, cookie will be
dropped otherwise cookie will stay.
On the next visit, we are going to capture the visit number and
compare it with the value stored in the cookie.
If the visit number == cookievalue +1 and booking abandon
cookie exists which means it is a subsequent visit.
So we will wait for the user to do a purchase. Once purchase is
done, another cookie will be dropped which will be picked up by
Target for personalization.
So thats how Target and DTM works together to get when it comes
to personalization for a specific audience.

Sample Code
var datenew = new Date();
datenew.setTime(datenew.getTime() + (365 * 24 * 60 * 60 * 1000));
var expires = "expires="+datenew.toUTCString();

var myCookie = getCookie("targetVoyageIDTemp");

if( lpn.indexOf("stateroom.do") != -1 && dtm_digitalData.voyageId != undefined &&


myCookie == null) {
document.cookie="targetVoyageIDTemp="+dtm_digitalData.voyageId+";" + expires +
";path=/";
}

if( lpn.indexOf("confirmation.do") != -1 && myCookie != null) {


document.cookie = "targetVoyageIDTemp=; expires=Thu, 01 Jan 1970 00:00:00 UTC;
path=/";
} */

Vous aimerez peut-être aussi