Setting data values with Previous page information as condition is not working

jaimebupa
Bronze Contributor
Bronze Contributor jaimebupa

We have a set of pages being tracked with events in our site. So if the customer lands in step-1 we fire an event. The problem is if the customer goes back from step-2 to step-1 we fire the event again.

To avoid this, I tried to create an extension that looks at the pagename and previous page name setting a new value in a variable if the previous page name doesn't equal step-2 or step-1.

I cannot make it to work.

Every time I try to use previos page name value in the extension my variable gets undefined. I looked and we have ct.s_ppn value BLR so not sure why isn't working. I also tried to use the mapping we have with adobe (use prop value instead of previous_page_name variable), changing when the tag should load, changing tag scope...

Does anyone knows why I'm unable to make it work? or knows how to use PPN as a condition for a set value data extension?

Thanks,

J

 

6 REPLIES 6

Setting data values with Previous page information as condition is not working

Tealium Expert
Tealium Expert

Hi

One of of resolving this i think is simply dropping a couple of flags as cookie. 

Then set conditions on the extention firing the event agaisnt those flags. 

ciao

 

Gavin

Research your Experience | Improve and Evolve | Leave no one behind

Setting data values with Previous page information as condition is not working

jaimebupa
Bronze Contributor
Bronze Contributor jaimebupa

Hi Gavin, Thanks for your answer!

Could you explain a littel more how could I do this?

At the moment I set up a cookie that tells me which step are the in in the journey. I was trying to store the value of the highest step they've been but couldn't work it out without creating one cookie for each step.

Really appreciate the help :)

Thanks

J

 

 

Highlighted

Setting data values with Previous page information as condition is not working

Tealium Expert
Tealium Expert

HI @jaimebupa 

So, here's what i'm thinking. 

You want a flag that allows you to only fire on first visit to a step. Subsequent views, should not fire a step. 

lets say you setup a cookie, called ct.step_visited

On first step page view, you drop the initial cookie with a value of 's1'

when the 2nd step is loaded, you read the same cookie and append the next step so the result should be an updated cookie with value 's1-s2'

and so on and so forth. 

The extention condition for firing the event should check that the cookie does not contain the flag for the relevant step. Page is Step 1 and Cookie does not contain s1

Even if you ended up with mulitple step visits so the cookie reads 's1-s2-s1' The condition will still work... 

then get rid of the cookie once the sequence is complete. 

Hope that helps

Research your Experience | Improve and Evolve | Leave no one behind

Setting data values with Previous page information as condition is not working

jaimebupa
Bronze Contributor
Bronze Contributor jaimebupa

Hi @GavinAttard,

Thanks so much for the detailed answer.

I'm going to use this approach, will let you know how it goes! :)

One more question I have. When you say at the end "get rid of the cookie" wouild it be enough to set it as a session cookie? Or how do I get rid of the cookie?

As you can see I'm not very experienced with cookies in general... :S

Thanks

J

Setting data values with Previous page information as condition is not working

Tealium Expert
Tealium Expert

HI @jaimebupa 

Pleasure, glad i could help. 

To 'get rid of a cookie', you effectivly expire the cookie. 

When setting it, set against a fixed time expiry, something long enough for the sequence, say 1 hour or so. 

When the sequence ends you simply update the cookie time setting to 0 time or an earlier time period and this will expire the cookie. 

The below code can also be used to drop a cookie using a javascript extention. Once you google your way to expert cookie knowledge, you will find that the below code can be reduced, based on your needs. 

var cookieName = "give me a name";
  var cookiePath = "/";
  var cookieValue = ;//Populate a value, this can be from a variable, or a fixed variable
  var expirationTime = 2628000; //For example one month in seconds (2628000)
  expirationTime = expirationTime * 1000; //Convert expirationtime to milliseconds
  var date = new Date(); //Create javascript date object
  var dateTimeNow = date.getTime(); //Get current time in milliseconds since 1 january 1970 (Unix time)
  date.setTime(dateTimeNow + expirationTime); //Set expiration time (Time now + one month)
  var expirationTime = date.toUTCString(); //Convert milliseconds to UTC time string. 
  document.cookie = cookieName + "=" + cookieValue + "; expires=" + expirationTime + "; path=" + cookiePath; //This drops the cookie - to expiire the cookie you can set expires=Thu, 01-Jan-70 00:00:01 GMT
Research your Experience | Improve and Evolve | Leave no one behind

Setting data values with Previous page information as condition is not working

jaimebupa
Bronze Contributor
Bronze Contributor jaimebupa

Hi @GavinAttard 

Thanks again! Really appreciate it 

Looks like I'll be a cookie expert in no time with all your support :p

Have a good day,

J