Skip to main content
Inspiring
December 11, 2019
Answered

Google Analytics

  • December 11, 2019
  • 2 replies
  • 945 views

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 has been closed for replies.
Correct answer kglad

google: javascript and google analytics.

2 replies

Participant
January 25, 2024

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.

 
 
 
 
kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
December 11, 2019

google: javascript and google analytics.

Inspiring
December 11, 2019

...and so you're right.

 

Specifically, this is pretty good.

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

 

Thank you.