Expand my Community achievements bar.

getPercentPageViewed plug in not working as expected

Avatar

Level 1

Hello,

I have implemented the getPercentPageViewed plugin, but I am not getting back any results. In installed the plugin by creating a rule and published it. I can see the function being added when I load the page. 

In the custom code tracker I added code to call the function: s.getPercentPageViewed() and then I tried to get data from the values set by the plugin:

if (s._ppvPreviousPage) {
console.log('_ppvPreviousPage: ', s._ppvPreviousPage)
console.log("initialPercent=" + s._ppvInitialPercentViewed + " | highestPercent=" + s._ppvHighestPercentViewed + " | finalPercent=" + s._ppvFinalPercentViewed + " | foldsAvailable=" + s._ppvFoldsAvailable + " | foldsSeen=" + s._ppvFoldsSeen)
}

I never see any meaningful data. I also never see any of the cookies being set by the plugin, even though I do see some other analytics cookie values being set.

Any feedback would be appreciated! Thank you!


Topics

Topics help categorize Community content and increase your ability to discover relevant content.

5 Replies

Avatar

Community Advisor

HI @JackieTu ,

I think you are under the wrong impression that the plugin creates additional properties on the "s" object.

Check out the documentation here, it states that these values are created on the "window" object.

Maybe try this instead

 

 

if (window._ppvPreviousPage) {
    console.log('_ppvPreviousPage: ', window._ppvPreviousPage)
    console.log("initialPercent=" + window._ppvInitialPercentViewed + " | highestPercent=" + window._ppvHighestPercentViewed + " | finalPercent=" + window._ppvFinalPercentViewed + " | foldsAvailable=" + window._ppvFoldsAvailable + " | foldsSeen=" + window._ppvFoldsSeen)
}

 

 

 
Cheers
Björn

Cheers from Switzerland!


Avatar

Level 1

Thank you for the quick reply. I saw that in the documentation as well, but I don't see any of those being set on the window. I only see the function and the variables being set on the s object. I even tried calling window.getPercentPageViewed and it says the function is not defined, I can only call it by s.getPercentPageViewed.

Avatar

Community Advisor

Hi @JackieTu 

the solution is that you will have to call s.getPercentPageViewed(); first to initialize the values.

 


Calling this function returns nothing; instead, it sets the following variables:

...

 

s.getPercentPageViewed();

console.log("initialPercent=" + s._ppvInitialPercentViewed + " | highestPercent=" + s._ppvHighestPercentViewed + " | finalPercent=" + s._ppvFinalPercentViewed + " | foldsAvailable=" + s._ppvFoldsAvailable + " | foldsSeen=" + s._ppvFoldsSeen);

 

 

This is how it looks for me

bk_work_0-1714979140248.png

Let me know if that works
Björn

Cheers from Switzerland!


Avatar

Level 1

I found the issue, there was actually a setting in my browser blocking the cookies being set so the plugin could not work correctly. Everything is working as expected now. Thank you for your help! 

Avatar

Community Advisor

Glad you figured it out!

Cheers from Switzerland!