Accepted Solutions (1)

Accepted Solutions (1)

christyw8416449

31-01-2018

Here is what I did, and hopefully it will work for you.  I created a new data element and set the type to custom script.  In the editor I added the getPreviousValue() and split() plugin code and then called getPreviousValue() with the current page name, returning the return value.  I use this data element on all page views to fill in a prop and an eVar with the previous page name.

Answers (5)

Answers (5)

haddnin

30-11-2018

Hello Christy, I like your approach because I'm not comfortable with putting it in Library Management so that I can keep my code most recent version. I'm working with a Single Page App, so i'm not sure if this will work. Something's not working correctly because I'm not seeing anything returned.

Here's my data element custom code:

    /*

    * Plugin: getPreviousValue_v1.0 - return previous value of designated

    *  variable (requires split utility)

    */

    var s = _satellite.getToolsByType('sc')[0].getS();

    s.getPreviousValue=new Function("v","c","el",""

    +"var s=this,t=new Date,i,j,r='';t.setTime(t.getTime()+1800000);if(el"

    +"){if(s.events){i=s.split(el,',');j=s.split(s.events,',');for(x in i"

    +"){for(y in j){if(i[x]==j[y]){if(s.c_r(c)) r=s.c_r(c);v?s.c_w(c,v,t)"

    +":s.c_w(c,'no value',t);return r}}}}}else{if(s.c_r(c)) r=s.c_r(c);v?"

    +"s.c_w(c,v,t):s.c_w(c,'no value',t);return r}");

    /*

    * Utility Function: split v1.5 - split a string (JS 1.0 compatible)

    */

    s.split=new Function("l","d",""

    +"var i,x=0,a=new Array;while(l){i=l.indexOf(d);i=i>-1?i:l.length;a[x"

    +"++]=l.substring(0,i);l=l.substring(i+d.length);}return a");

    return(s.getPreviousValue(s.pageName,'gpv_pn', 'event1'));

Does this look like your implementation?

Thanks!

Abhijeet_Mishra

Employee

23-01-2018

Hi,

You can use the 'getpreviousvalue' plug-in to achieve this.

Using this plug-in, you can capture the value of an Analytics variable on the next page view. For an example, capturing the s.pageName value from the previous page view into a Custom Traffic variable i.e. previous page value in a variable of your choice.

srikanths356410

23-01-2018

Hi Jantzen Belliston,

Thanks for helping me. Right now my next page flow reports have data in it. I would like to have a prop to capture them so that i can use it in my analysis workspace. But can you explain more about how to setup previous page report into a prop using cookie or data element?

jantzen_belliston-Adobe

Community Manager

23-01-2018

Within Analytics, you could look into the pathing or previous page report.

Pathing

Previous Page

As for DTM, you could do this a number of ways, I'll list a few below:

1) Store the Page Name in a cookie or data element and retrieve and set to a prop when needed

2) Set the previous page name in a query string (site.com/page2?ppn=page1) and retrieve it when needed

3) If you are just looking for the referring domain (IE if someone found your site via another domain or search engine) you could tap into document.referrer for the referring URL.

Thanks,
Jantzen