Skip to main content
Inspiring
December 11, 2019
解決済み

Google Analytics

  • December 11, 2019
  • 返信数 2.
  • 954 ビュー

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.

このトピックへの返信は締め切られました。
解決に役立った回答 kglad

google: javascript and google analytics.

返信数 2

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 Expert解決!
Community Expert
December 11, 2019

google: javascript and google analytics.

Freelance77作成者
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.