Skip to main content
Inspiring
Dec 11, 2019 10:00 PM UTC
Answered

Google Analytics

Hello,

 

Looking to hopefully have Google analytics pick-up when a user reaches a certain (canvas) frame - roughly, a frame would equal a page on a normal website as far as GA is concerned. Is this possible to do? ..and if so, could you please advise the script for the frame?

 

Thank you.

This topic is closed to new replies. Start a new post to keep the conversation going.
kglad
kgladCorrect answer
Community Expert
Dec 11, 2019 10:38 PM UTC

google: javascript and google analytics.

3 replies

Participant
Jan 25, 2024 7:09 AM UTC

Yes, it's possible. You can use the following JavaScript code to trigger a virtual pageview in Google Analytics when a user reaches a specific point in the frame:

html
<script>document.getElementById('canvasFrame').contentWindow.onscroll = function() { var scrollThreshold = 500; if (document.getElementById('canvasFrame').contentWindow.pageYOffset >= scrollThreshold) { ga('send', 'pageview', '/virtual/page/on/canvas-frame'); } }; </script>

Adjust the scrollThreshold and virtual page path as needed. Make sure your Google Analytics tracking code is properly set up on your website.

 
 
 
 
Translate
kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
Dec 11, 2019 10:38 PM UTC

google: javascript and google analytics.

Translate
Inspiring
Dec 11, 2019 10:52 PM UTC

...and so you're right.

 

Specifically, this is pretty good.

https://www.optimizesmart.com/beginners-guide-to-javascript-for-google-analytics/#a3

 

Thank you.

Translate