In designing the deployment scheme of Adobe Analytics, some people set the Previous Page to an eVar or props for analysis, so they need to obtain the Previous Page.
There are many ways to get previous pages in Adobe Launch.
Plug in: getPreviousValue
The Adobe Consulting team provides a plug-in getPreviousValue, which allows you to set a variable to the value set at the last click.
First, install the plug-in. The plug-in code is as follows:
/* Adobe Consulting Plugin: getPreviousValue v3.0 */ function getPreviousValue(v,c){var k=v,d=c;if("-v"===k)return{plugin:"getPreviousValue",version:"3.0"};var a=function(){if("undefined"!==typeof window.s_c_il)for(var c=0,b;c<window.s_c_il.length;c++)if(b=window.s_c_il[c],b._c&&"s_c"===b._c)return b}();"undefined"!==typeof a&&(a.contextData.getPreviousValue="3.0");window.cookieWrite=window.cookieWrite||function(c,b,f){if("string"===typeof c){var h=window.location.hostname,a=window.location.hostname.split(".").length-1;if(h&&!/^[0-9.]+$/.test(h)){a=2<a?a:2;var e=h.lastIndexOf(".");if(0<=e){for(;0<=e&&1<a;)e=h.lastIndexOf(".",e-1),a--;e=0<e?h.substring(e):h}}g=e;b="undefined"!==typeof b?""+b:"";if(f||""===b)if(""===b&&(f=-60),"number"===typeof f){var d=new Date;d.setTime(d.getTime()+6E4*f)}else d=f;return c&&(document.cookie=encodeURIComponent(c)+"="+encodeURIComponent(b)+"; path=/;"+(f?" expires="+d.toUTCString()+";":"")+(g?" domain="+g+";":""),"undefined"!==typeof cookieRead)?cookieRead(c)===b:!1}};window.cookieRead=window.cookieRead||function(c){if("string"===typeof c)c=encodeURIComponent(c);else return"";var b=" "+document.cookie,a=b.indexOf(" "+c+"="),d=0>a?a:b.indexOf(";",a);return(c=0>a?"":decodeURIComponent(b.substring(a+2+c.length,0>d?b.length:d)))?c:""};var l;d=d||"s_gpv";a=new Date;a.setTime(a.getTime()+18E5);window.cookieRead(d)&&(l=window.cookieRead(d));k?window.cookieWrite(d,k,a):window.cookieWrite(d,l,a);return l}; /******************************************** END CODE TO DEPLOY ********************************************/
It can be installed with a custom code editor, AppMeasurement, or Adobe Analytics Extensions in a variety of ways.
After installation, you can use this plug-in. The usage of this plug-in is
getPreviousValue(v,c)
- v (string, required): a variable with a value to pass to the next image request. The common variable used to retrieve the value of the previous page is s.pageName.
- c (string, optional): the name of the Cookie used to store the value. If this parameter is not set, "s_gpv" is used by default.
When this function is called, the string value contained in the Cookie is returned. The plug-in then resets the Cookie expiration time and assigns it the variable value in the v parameter. The Cookie will expire after 30 minutes of inactivity.
Its function is that when executing, V is the current page, C is the upper page stored in the cookie, it will obtain the value in the cookie, that is, previous page, and then update the current page V to the cookie.
Now I visit page A-B-C and set the previous page to prop1 to see how they are assigned on different pages
Visit page A: getPreviousValue(v,c). v is a, C is empty, and a is in the Cookie
Visit page B: getPreviousValue(v,c). In the cookie, it is A, v is B, C is A, and the cookie is B
Visit page C: getPreviousValue(v,c). In the cookie, it is B, v is C, C is B, and in the cookie, it is C
If events are involved in the access process, it is different. Suppose that the user triggers event E before accessing B, and the order of server calls sent is A-E-B-C
Visit page A: getPreviousValue(v,c). v is a, C is empty, and a is in the Cookie
Visit page B: getPreviousValue(v,c). E is in the cookie, v is B, C is e, and B is in the cookie
Visit page C: getPreviousValue(v,c). In the cookie, it is B, v is C, C is B, and in the cookie, it is C
When accessing page B, its previous page is the page in E, that is, the page in the event. See which page the event is triggered on. If it is triggered on page A, then E is A. if it is triggered on page B, then E is B.
Page Info in data element
In the Page Info data element of Launch, there is a reference, which is the source of the previous page, which can be used directly:

Its assignment logic depends on the execution location of the plug-in getPreviousValue and the settings of Page View and Page Event.
document.referrer
document. Reference is supported by the browser by default. All pages can use this function to obtain the source of the upper level page. It can be stored in the data element with custom code through document The Previous Page obtained by the referrer.
document. The reference is the same as the reference in page info. Page info is only encapsulated and can be used directly.
So there's no need to use document Refer to this method.
It is generally recommended to use Page Info, but understand the assignment of different requests.