Expand my Community achievements bar.

SOLVED

getPercentPageViewed v3.0 plug in question

Avatar

Community Advisor

Hello Team,

I am using the new plugin getPercentPageViewed v3.0 with getPreviousValue but somehow its not working correctly.

I have implemented like below

Added both the plugin code in PLUGIN Section, and doPlugin section added below code.

s.prop9 = s.getPreviousValue(s.pageName, 's_ppn', '');

if (s.pageName !== undefined) {

var ppv = s.getPercentPageViewed(s.pageName); // passing the page name as parameter

if (ppv) {

s.prop9 = ppv[0]; // contains the previous page name

s.prop55 = ppv[1]; // contains the total percent viewed

s.prop56 = ppv[2]; // contains the percent viewed on initial load

s.prop54 = ppv[3]; // contains the total number of vertical pixels

}

}

getting the result as undefined. s.getPercentPageViewed(s.pageName) is not executing. Even though I tried to debug the plugin code, it says pid is not defined.

Please check attached screenshot

1671132_pastedImage_0.png

Can someone please help ?

Thanks

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Plugins are owned by our consulting team - they would be the absolute best individuals to help figure out what's wrong and provide a solution. If you'd like to go that route, please get in touch with your organization's account manager.

View solution in original post

6 Replies

Avatar

Employee Advisor

Hm, yeah, that's strange. Your code looks normal, so I'm not sure what it could be.

I just found that there's a v3.01. Want to try that and see if it works any better?

/*************************************************************************************************************

* Adobe Consulting Plugin: getPercentPageViewed v3.01

*

* Requires AppMeasurement, the handlePPVevents helper function, and the p_fo plugin (included in the BEGIN CODE TO DEPLOY section)

*

* Release Date: 2018-08-13

*

* Arguments to Pass In:

* pid (optional, string) - a variable that you want to tie the percentage of page viewed to. This would usually be some sort of page identifier. Defaults to the Analytics pageName OR the current URL if not set.

* ch (optional, boolean) - set this equal to false if you don't want the plugin to take into consideration any changes made to the page size after its initial load. true is the recommended/default value for this Argument

*

* Returns:

* Nothing, but will set the following variables in the AppMeasurement object as a new page loads:

* s._ppvPreviousPage = The name of the previous page viewed (As final measurements aren't available until a NEW page loads)

* s._ppvHighestPercentViewed = The highest percent of the previous page that the visitor viewed (height-wise); in other words, what was the furthest point that the visitor scrolled down on the page

* s._ppvInitialPercentViewed = The percent of the previous page that was visible when the previous page *first* loaded

* s._ppvHighestPixelsSeen = The highest number of total pixels seen (height-wise) as the visitor scrolled down in the previous page

*

* Sample Calls:

* s.getPercentPageViewed()

*

* if(s.pageName) s.getPercentPageViewed();

* if(s._ppvPreviousPage)

* {

* s.prop1 = s._ppvPreviousPage;

* s.prop2 = 'highestPercentViewed = ' + s._ppvHighestPercentViewed + ' | initialPercentViewed=' + s._ppvInitialPercentViewed;

* }

*

*************************************************************************************************************/

/******************************************* BEGIN CODE TO DEPLOY *******************************************/

/* Adobe Consulting Plugin: getPercentPageViewed v3.01 w/handlePPVevents helper function (Requires AppMeasurement and the p_fo plugin) */

s.getPercentPageViewed=function(pid,ch){var s=this,a=s.c_r("s_ppv");a=-1<a.indexOf(",")?a.split(","):[];a[0]=s.unescape(a[0]);pid=pid?pid:s.pageName?s.pageName:document.location.href;s.ppvChange=ch?ch:!0;if("undefined"===typeof s.linkType||"o"!==s.linkType)s.ppvID&&s.ppvID===pid||(s.ppvID=pid,s.c_w("s_ppv",""),s.handlePPVevents()),s.p_fo("s_gppvLoad")&&window.addEventListener&&(window.addEventListener("load",s.handlePPVevents,!1),window.addEventListener("click",s.handlePPVevents,

!1),window.addEventListener("scroll",s.handlePPVevents,!1),window.addEventListener("resize",s.handlePPVevents,!1)),s._ppvPreviousPage=a[0]?a[0]:"",s._ppvHighestPercentViewed=a[1]?a[1]:"",s._ppvInitialPercentViewed=a[2]?a[2]:"",s._ppvHighestPixelsSeen=a[3]?a[3]:""};

/* Adobe Consulting Plugin: handlePPVevents helper function (for getPercentPageViewed v3.01 Plugin) */

s.handlePPVevents=function(){if("undefined"===typeof s_c_il){for(var c=0,d=s_c_il.length;c<d;c++)if(s_c_il[c]&&s_c_il[c].getPercentPageViewed){var a=s_c_il[c];break}if(a&&a.ppvID){var f=Math.max(Math.max(document.body.scrollHeight,document.documentElement.scrollHeight),Math.max(document.body.offsetHeight,document.documentElement.offsetHeight),Math.max(document.body.clientHeight,document.documentElement.clientHeight));c=(window.pageYOffset||window.document.documentElement.scrollTop||window.document.body.scrollTop)+

(window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight);d=Math.min(Math.round(c/f*100),100);var e="";!a.c_r("s_tp")||a.unescape(a.c_r("s_ppv").split(",")[0])!==a.ppvID||1==a.ppvChange&&a.c_r("s_tp")&&f!=a.c_r("s_tp")?(a.c_w("s_tp",f),a.c_w("s_ppv","")):e=a.c_r("s_ppv");var b=e&&-1<e.indexOf(",")?e.split(",",4):[];f=0<b.length?b[0]:escape(a.ppvID);var g=1<b.length?parseInt(b[1]):d,h=2<b.length?parseInt(b[2]):d;b=3<b.length?parseInt(b[3]):c;0<d&&(e=f+","+(d>g?d:g)+","+

h+","+(c>b?c:b));a.c_w("s_ppv",e)}}};

/* Adobe Consulting Plugin: p_fo (pageFirstOnly) v2.0 (Requires AppMeasurement) */

s.p_fo=function(on){var s=this;s.__fo||(s.__fo={});if(s.__fo[on])return!1;s.__fo[on]={};return!0};

/******************************************** END CODE TO DEPLOY ********************************************/

Avatar

Community Advisor

ericmatisoff

Thanks for reply.  is getPercentPageViewed v 3.01 just released ? Though I am using getPercentPageViewed v3.0 from this link and still facing the same issue as described above?

Avatar

Community Advisor

I am seeing different result when below statements are getting executed. Not sure why this happens.

// Fetching the previous page name using below

s.prop25 = s.getPreviousValue(s.pageName, 'gpv_nn', '');

s._ppvPreviousPage;  showing different value.

Ideally, getPreviousValue and the value getting in s._ppvPreviousPage should be same but getting different result ?

May I know is there co-relation between these two ? or it should be run independently.

Gigazelle ParitMittalTanmayMericmatisoff  Anyone can help here ?

Avatar

Correct answer by
Employee Advisor

Plugins are owned by our consulting team - they would be the absolute best individuals to help figure out what's wrong and provide a solution. If you'd like to go that route, please get in touch with your organization's account manager.

Avatar

Level 1

Gigazelle​  ericmatisoff​ : While using the 3.01 getPercentPageViewed plugin, the browser is throwing an error. Where can i find this function to stick in the s_code file ?

Uncaught TypeError: s.unescape is not a function

Avatar

Employee Advisor

Unfortunately, neither Russ nor I am quite qualified to provide support on plugins, so the answer is the same as above:

Plugins are owned by our consulting team - they would be the absolute best individuals to help figure out what's wrong and provide a solution. If you'd like to go that route, please get in touch with your organization's account manager.

6.2.5