URGENT : Getting console error when using s.getPercentPageViewed plugin | Community
Skip to main content
New Participant
November 7, 2016
Solved

URGENT : Getting console error when using s.getPercentPageViewed plugin

  • November 7, 2016
  • 17 replies
  • 10927 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by ParitMittal

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

17 replies

ShamshulA
Employee
August 24, 2017

The bug ID to update the document is AN-147411

lytics
New Participant
August 10, 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
New Participant
August 2, 2017

Okay, thanks.

jantzen_b
Employee
August 2, 2017

Let me track down the owner of that plug-in to see if we can get the information that we need.

jakeg58042588
New Participant
July 31, 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.

Gigazelle
Employee
July 28, 2017

I'm afraid not, sorry.

jantzen_b
Employee
July 28, 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?

jakeg58042588
New Participant
July 28, 2017

Jantzen, I am not seeing the new version (2.01) in the documentation. Can someone at Adobe add this?

jantzen_b
Employee
July 28, 2017

Here is the documentation getPercentPageViewed

jakeg58042588
New Participant
July 27, 2017

Where can the new version of this plugin be found in the official Adobe documentation?