Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

getPercentPageViewed plug in question

scottt6073095
Level 6
Level 6

Do I need to create a data element and / or page load rule for the getPercentPageViewed plug in to work? I assume I have to do the following but please let me know if I missed anything:

  1. Add plug in code to website
  2. Add code to s_code file for getPercentPageViewed v1.71
  3. Use existing pageload rule (Content: All Pages) and add a sprop for getPercentPageViewed
  4. Add traffic variable to report suite
  5. Create a classification for Less than 25%, Less than 50%, more than 50%, more than 75% and 100%
1 Accepted Solution
ParitMittal
Correct answer by
Level 10
Level 10

Hi  Scott,

There is no need to create a separate data element for capturing the percentage page viewed.  Please note that the plugin Record the portion of a page (0-100%) that the user views and pass the value into a variable on the next page view.

Ex- If user views a page say " Page A" and scrolls till  70% of the page and then clicks a link on "Page A" and moves to "Page B" . Hence on load of "Page B", The Percentage of Page view value captured is for "Page A" and the value is 70%.

Please follow the following steps and you will be good to go with percentage page viewed plugin.

  • Add plug in code to s_code file in plugins section.
  • /*plugin to capture previous value */ 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"); s.getPercentPageViewed=new Function("n","" +"var s=this,W=window,EL=W.addEventListener,AE=W.attachEvent,E=['load" +"','unload','scroll','resize','zoom','keyup','mouseup','touchend','o" +"rientationchange','pan'];W.s_Obj=s;s_PPVid=(n=='-'?s.pageName:n)||s" +".pageName||location.href;if(!W.s_PPVevent){s.s_PPVg=function(n,r){v" +"ar k='s_ppv',p=k+'l',c=s.c_r(n||r?k:p),a=c.indexOf(',')>-1?c.split(" +"',',10):[''],l=a.length,i;a[0]=unescape(a[0]);r=r||(n&&n!=a[0])||0;" +"a.length=10;if(typeof a[0]!='string')a[0]='';for(i=1;i<10;i++)a[i]=" +"!r&&i<l?parseInt(a[i])||0:0;if(l<10||typeof a[9]!='string')a[9]='';" +"if(r){s.c_w(p,c);s.c_w(k,'?')}return a};W.s_PPVevent=function(e){va" +"r W=window,D=document,B=D.body,E=D.documentElement,S=window.screen|" +"|0,Ho='offsetHeight',Hs='scrollHeight',Ts='scrollTop',Wc='clientWid" +"th',Hc='clientHeight',C=100,M=Math,J='object',N='number',s=W.s_Obj|" +"|W.s||0;e=e&&typeof e==J?e.type||'':'';if(!e.indexOf('on'))e=e.subs" +"tring(2);s_PPVi=W.s_PPVi||0;if(W.s_PPVt&&!e){clearTimeout(s_PPVt);s" +"_PPVt=0;if(s_PPVi<2)s_PPVi++}if(typeof s==J){var h=M.max(B[Hs]||E[H" +"s],B[Ho]||E[Ho],B[Hc]||E[Hc]),X=W.innerWidth||E[Wc]||B[Wc]||0,Y=W.i" +"nnerHeight||E[Hc]||B[Hc]||0,x=S?S.width:0,y=S?S.height:0,r=M.round(" +"C*(W.devicePixelRatio||1))/C,b=(D.pageYOffset||E[Ts]||B[Ts]||0)+Y,p" +"=h>0&&b>0?M.round(C*b/h):0,O=W.orientation,o=!isNaN(O)?M.abs(o)%180" +":Y>X?0:90,L=e=='load'||s_PPVi<1,a=s.s_PPVg(s_PPVid,L),V=function(i," +"v,f,n){i=parseInt(typeof a==J&&a.length>i?a[i]:'0')||0;v=typeof v!=" +"N?i:v;v=f||v>i?v:i;return n?v:v>C?C:v<0?0:v};if(new RegExp('(iPod|i" +"Pad|iPhone)').exec(navigator.userAgent||'')&&o){o=x;x=y;y=o}o=o?'P'" +":'L';a[9]=L?'':a[9].substring(0,1);s.c_w('s_ppv',escape(W.s_PPVid)+" +"','+V(1,p,L)+','+(L||!V(2)?p:V(2))+','+V(3,b,L,1)+','+X+','+Y+','+x" +"+','+y+','+r+','+a[9]+(a[9]==o?'':o))}if(!W.s_PPVt&&e!='unload')W.s" +"_PPVt=setTimeout(W.s_PPVevent,333)};for(var f=W.s_PPVevent,i=0;i<E." +"length;i++)if(EL)EL(E[i],f,false);else if(AE)AE('on'+E[i],f);f()};v" +"ar a=s.s_PPVg();return!n||n=='-'?a[1]:a");
  • Add below code in the doplugins() function to s_code file for capturing  getPercentPageView, get previous value in respective s.prop variable  Alternatively you can also add the below code to an existing pageload rule (Content: All Pages). 
  • s.usePlugins=true function s_doPlugins(s) { s.prop9 = s.getPreviousValue(s.pageName,'s_ppn'); //prop9: prev page name s.prop10 = s.getPercentPageViewed(); //prop10: max % viewed of prev page if(!s.prop9||s.prop10=='no value')s.prop10=''; //clear max % viewed if no prev page view } s.doPlugins=s_doPlugins
  •    Add traffic variable to report suite
  • Create a classification for Less than 25%, Less than 50%, more than 50%, more than 75% and 100%

Please let us know in case of any questions or queries.

Thanks & Regards

Parit Mittal

View solution in original post

2 Replies
ParitMittal
Correct answer by
Level 10
Level 10

Hi  Scott,

There is no need to create a separate data element for capturing the percentage page viewed.  Please note that the plugin Record the portion of a page (0-100%) that the user views and pass the value into a variable on the next page view.

Ex- If user views a page say " Page A" and scrolls till  70% of the page and then clicks a link on "Page A" and moves to "Page B" . Hence on load of "Page B", The Percentage of Page view value captured is for "Page A" and the value is 70%.

Please follow the following steps and you will be good to go with percentage page viewed plugin.

  • Add plug in code to s_code file in plugins section.
  • /*plugin to capture previous value */ 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"); s.getPercentPageViewed=new Function("n","" +"var s=this,W=window,EL=W.addEventListener,AE=W.attachEvent,E=['load" +"','unload','scroll','resize','zoom','keyup','mouseup','touchend','o" +"rientationchange','pan'];W.s_Obj=s;s_PPVid=(n=='-'?s.pageName:n)||s" +".pageName||location.href;if(!W.s_PPVevent){s.s_PPVg=function(n,r){v" +"ar k='s_ppv',p=k+'l',c=s.c_r(n||r?k:p),a=c.indexOf(',')>-1?c.split(" +"',',10):[''],l=a.length,i;a[0]=unescape(a[0]);r=r||(n&&n!=a[0])||0;" +"a.length=10;if(typeof a[0]!='string')a[0]='';for(i=1;i<10;i++)a[i]=" +"!r&&i<l?parseInt(a[i])||0:0;if(l<10||typeof a[9]!='string')a[9]='';" +"if(r){s.c_w(p,c);s.c_w(k,'?')}return a};W.s_PPVevent=function(e){va" +"r W=window,D=document,B=D.body,E=D.documentElement,S=window.screen|" +"|0,Ho='offsetHeight',Hs='scrollHeight',Ts='scrollTop',Wc='clientWid" +"th',Hc='clientHeight',C=100,M=Math,J='object',N='number',s=W.s_Obj|" +"|W.s||0;e=e&&typeof e==J?e.type||'':'';if(!e.indexOf('on'))e=e.subs" +"tring(2);s_PPVi=W.s_PPVi||0;if(W.s_PPVt&&!e){clearTimeout(s_PPVt);s" +"_PPVt=0;if(s_PPVi<2)s_PPVi++}if(typeof s==J){var h=M.max(B[Hs]||E[H" +"s],B[Ho]||E[Ho],B[Hc]||E[Hc]),X=W.innerWidth||E[Wc]||B[Wc]||0,Y=W.i" +"nnerHeight||E[Hc]||B[Hc]||0,x=S?S.width:0,y=S?S.height:0,r=M.round(" +"C*(W.devicePixelRatio||1))/C,b=(D.pageYOffset||E[Ts]||B[Ts]||0)+Y,p" +"=h>0&&b>0?M.round(C*b/h):0,O=W.orientation,o=!isNaN(O)?M.abs(o)%180" +":Y>X?0:90,L=e=='load'||s_PPVi<1,a=s.s_PPVg(s_PPVid,L),V=function(i," +"v,f,n){i=parseInt(typeof a==J&&a.length>i?a[i]:'0')||0;v=typeof v!=" +"N?i:v;v=f||v>i?v:i;return n?v:v>C?C:v<0?0:v};if(new RegExp('(iPod|i" +"Pad|iPhone)').exec(navigator.userAgent||'')&&o){o=x;x=y;y=o}o=o?'P'" +":'L';a[9]=L?'':a[9].substring(0,1);s.c_w('s_ppv',escape(W.s_PPVid)+" +"','+V(1,p,L)+','+(L||!V(2)?p:V(2))+','+V(3,b,L,1)+','+X+','+Y+','+x" +"+','+y+','+r+','+a[9]+(a[9]==o?'':o))}if(!W.s_PPVt&&e!='unload')W.s" +"_PPVt=setTimeout(W.s_PPVevent,333)};for(var f=W.s_PPVevent,i=0;i<E." +"length;i++)if(EL)EL(E[i],f,false);else if(AE)AE('on'+E[i],f);f()};v" +"ar a=s.s_PPVg();return!n||n=='-'?a[1]:a");
  • Add below code in the doplugins() function to s_code file for capturing  getPercentPageView, get previous value in respective s.prop variable  Alternatively you can also add the below code to an existing pageload rule (Content: All Pages). 
  • s.usePlugins=true function s_doPlugins(s) { s.prop9 = s.getPreviousValue(s.pageName,'s_ppn'); //prop9: prev page name s.prop10 = s.getPercentPageViewed(); //prop10: max % viewed of prev page if(!s.prop9||s.prop10=='no value')s.prop10=''; //clear max % viewed if no prev page view } s.doPlugins=s_doPlugins
  •    Add traffic variable to report suite
  • Create a classification for Less than 25%, Less than 50%, more than 50%, more than 75% and 100%

Please let us know in case of any questions or queries.

Thanks & Regards

Parit Mittal

View solution in original post

scottt6073095
Level 6
Level 6

Very helpful. So if it's an Adobe plugin then I just have to drop code in the s_code file? Also, what is best practices for adding the  "doplugins() function"; should it be in the pageload rule or should I just add it to the s_code file to keep everything in one place? Are there ramifications for putting the  doplugins() function in the s_code file rather than the page load rule?

thanks again for all your help