URGENT : Getting console error when using s.getPercentPageViewed plugin

ankits3107362

07-11-2016

Hi,

I did implemented the getPercentPageViewed into my s_code file using the DTM tool.

And i am getting the following error message on blog site and for rest of the sites its working perfectly.Not sure whats the issue.

Uncaught TypeError: s.s_PPVg is not a function

URL: https://blogs.nvidia.com/blog/category/virtual-reality/

Please help me with this.

Thanks

Ankit

Accepted Solutions (1)

Accepted Solutions (1)

ParitMittal

11-11-2016

Hi Ankit,

Please use version v2.01 of getpercentpageviewed() analytics plugin , Also Please find attached documentation for the same.

How To Implement
•    Copy + Paste the minified code (see below) to anywhere within the Plugins section of the AppMeasurement code
•    Run the getPercentPageView function as needed within the doPlugins function (see sample calls below)
Parameters
pid (optional): current page identifier. Defaults to s.pageName OR, if s.pageName is not set, the URL 
change (optional): set equal to '0' if you do not want to track dynamic changes to the page length
Returns
The getPecentPageViewed plugin returns an array of identifiers mentioned below.
•    array[0] contains the identifier (e.g. the previous s.pageName value)
•    array[1] contains the highest percent viewed of the previous page
•    array[2] contains the percent of the previous page viewed on its initial load
•    array[3] contains the highest number of vertical pixels viewed of the previous page
If pid is equal to "-", will return only the highest percent viewed of the previous page in a non-Array JavaScript variable (not recommended)
Sample Calls
Example #1
If… Previous pageName is “shop|buyflow|customize” and current pageName is “shop|buyflow|customer info”

…and the following code runs on the current page…
if(s.pageName){
var ppvArray = s.getPercentPageViewed();
}
if(typeof ppvArray != 'undefined' && typeof ppvArray[1] != 'undefined')
    {
        s.prop1 = 'initialpercent=' + ppvArray[2]
         s.prop2 = 'highestpercent=' + ppvArray[1];
        s.prop3 = ppvArray[0];
    }
    else{
        s.prop1 = s.prop2 = s.prop3 = "";
}
… the final value of s.prop1, s.prop2,prop3 will be:
s.prop1="initialpercent=60"
s.prop2="heighestpercent=100"
s.prop3="shop|buyflow|cusotmize"
Example #2
If… Previous pageName is “shop|buyflow|customize” and current pageName is “shop|buyflow|customer info”

…and the following code runs on the current page…
if(s.pageName){
var ppvArray = s.getPercentPageViewed('','0');
}
if(typeof ppvArray != 'undefined' && typeof ppvArray[1] != 'undefined')
    {
        s.prop1 = 'initialpercent=' + ppvArray[2]
         s.prop2 = 'highestpercent=' + ppvArray[1];
        s.prop3 = ppvArray[0];
    }
    else{
        s.prop1 = s.prop2 = s.prop3 = "";
}
… the final value of s.prop1, s.prop2,prop3 will be: will do no recalculations if the page dynamically changes its vertical height in pixels
s.prop1="initialpercent=60"
s.prop2="heighestpercent=100"
s.prop3="shop|buyflow|cusotmize"
Example #3
If… Previous pageName is “shop|buyflow|customize” and current pageName is “shop|buyflow|customer info”

…and the following code runs on the current page…
if(s.pageName){
var ppvArray = s.getPercentPageViewed();
}
if(typeof ppvArray != 'undefined' && typeof ppvArray[1] != 'undefined')
    {
        
        s.prop4 = 'highestpixel=' + ppvArray[3];
    }
    else{
        s.prop4 "";
}
… the final value of s.prop4 will be: highest number of vertical pixels viewed of the previous page
s.prop4=" highestpixel =5132"

Example #4 (Recommanded)
If… Previous pageName is “shop:buyflow:customize” and current pageName is “shop:buyflow:customer info”

…and the following code runs on the current page…
if(s.pageName){
var ppvArray = s.getPercentPageViewed();
}
if(typeof ppvArray != 'undefined' && typeof ppvArray[1] != 'undefined')
    {
        s.prop1 = 'initialpercent=' + ppvArray[2]+ '|highestpercent=' + ppvArray[1]+ '|'+ ppvArray[0]+'|heightpixel =' ppvArray[3];

    }
    else{
        s.prop1 ="";
}
… the final value of s.prop1 will be:
s.prop1="initialpercent=60| heighestpercent=100|shop:buyflow:cusotmize|highestpixel=5132 "
S Object Replacement
When instantiating the main AppMeasurement library object with a name other than "s", change the following portion of the plugin code from this…
s.getPercentPageViewed = function(pid, change)
…to this:
[objectname].getPercentPageViewed = function(pid, change)

Reporting/Backend Setup (Requires Admin Access)
Prop setup
Setup the Prop that will hold the Percent Page Viewed data with the following attributes:
•    Name: Percent Page Viewed
•    Description: Percent Page Viewed concatenated value
•    List Support: Disabled
•    All other attributes use the default values provided

Code Minified Code /* Plugin: getPercentPageViewed v2.01 */ s.handlePPVevents=function(){if(!s_c_il)return;for(var i=0,scill=s_c_il.length;i<scill;i++)if(typeof s_c_il[i]!="undefined"&&s_c_il[i]._c&&s_c_il[i]._c=="s_c"){var s=s_c_il[i];break}if(!s)return;if(!s.getPPVid)return;var dh=Math.max(Math.max(s.d.body.scrollHeight,s.d.documentElement.scrollHeight),Math.max(s.d.body.offsetHeight,s.d.documentElement.offsetHeight),Math.max(s.d.body.clientHeight,s.d.documentElement.clientHeight)),vph=window.innerHeight||(s.d.documentElement.clientHeight||s.d.body.clientHeight), st=window.pageYOffset||(window.document.documentElement.scrollTop||window.document.body.scrollTop),vh=st+vph,pv=Math.min(Math.round(vh/dh*100),100),c="",p=s.c_r("s_ppv").split(",")[0];if(!s.c_r("tp")||(s.unescape?s.unescape(p):decodeURIComponent(p))!=s.getPPVid||s.ppvChange=="1"&&(s.c_r("tp")&&dh!=s.c_r("tp"))){s.c_w("tp",dh);s.c_w("s_ppv","")}else c=s.c_r("s_ppv");var a=c&&c.indexOf(",")>-1?c.split(",",4):[],id=a.length>0?a[0]:escape(s.getPPVid),cv=a.length>1?parseInt(a[1]):0,p0=a.length>2?parseInt(a[2]): pv,cy=a.length>3?parseInt(a[3]):0,cn=pv>0?id+","+(pv>cv?pv:cv)+","+p0+","+(vh>cy?vh:cy):"";s.c_w("s_ppv",cn)}; s.getPercentPageViewed=function(pid,change){var s=this,ist=!s.getPPVid?true:false;pid=pid?pid:s.pageName?s.pageName:document.location.href;s.ppvChange=change?change:"1";if(typeof s.linkType!="undefined"&&s.linkType!="0"&&s.linkType!=""&&s.linkType!="e")return"";var v=s.c_r("s_ppv"),a=v.indexOf(",")>-1?v.split(",",4):[];if(a&&a.length<4){for(var i=3;i>0;i--)a[i]=i<a.length?a[i-1]:"";a[0]=""}if(a)a[0]=unescape(a[0]);if(!s.getPPVid||s.getPPVid!=pid){s.getPPVid=pid;s.c_w("s_ppv",escape(s.getPPVid));s.handlePPVevents()}if(ist)if(window.addEventListener){window.addEventListener("load", s.handlePPVevents,false);window.addEventListener("click",s.handlePPVevents,false);window.addEventListener("scroll",s.handlePPVevents,false);window.addEventListener("resize",s.handlePPVevents,false)}else if(window.attachEvent){window.attachEvent("onload",s.handlePPVevents);window.attachEvent("onclick",s.handlePPVevents);window.attachEvent("onscroll",s.handlePPVevents);window.attachEvent("onresize",s.handlePPVevents)}return pid!="-"?a:a[1]};

 

Thanks & Regards 

Parit Mittal

Answers (16)

Answers (16)

lytics

10-08-2017

If the plugin is loaded twice, this issue will definitely occur. Depending on your tag manager, getPercentPageViewed might be assigned to pages/urls in more than one place by mistake.

jakeg58042588

31-07-2017

So, can the plugin Parit posted be added to the official documentation? I don't think it makes sense that someone would need to search the forums to find it.

jantzen_belliston-Adobe

Community Manager

28-07-2017

I'm going to tag our Analytics community manager to see if they have more info on this plugin

Gigazelle​ - Do you have any info about a new version of the getPercentPageViewed plugin?

lytics

05-07-2017

ParitMittal

I am experiencing this issue on a retail eCommerce site with Single Page App framework (ReactJS), perhaps you could help us:

AppMeasurement v1.6

Plugin: getPercentPageViewed v1.71

I'm unsure if updating the Plugin is the right solution for our implementation, also I have not seen your suggested version updated in the Adobe Implementation Guide, here.

I would be glad to share the url where the error occurs via PM.

ankits3107362

11-11-2016

Hi Parit,

Where i can find the updated documentation of plugins.

Similar to this i am having issue with previous page plugin.

Please help me with this.

Thanks

Ankit

ParitMittal

09-11-2016

Hi Ankit,

There seems to be a compatibility issue of Plugin version being used with the App Measurement version. Since your are using Plugin v1.71 and Appmeasurement version 1.6.4 , Can you please confirm whether the sites where no error is being throw the same version of plugin & App Measurement library are being used.

Thanks & Regards

Parit Mittal