I was asked to implement the Google Tag Manager (GTM) into my Playcanvas scene to track how long each video is played. I was able to make it work when you launch it from the editor: https://playcanvas.com/editor/scene/1211524
The dataLayer array gets filled with events every time you watch a video, see below.
thanks for having a look at it. Maybe I don’t need any fix for that:
I just realized since the scene will be embedded via iframe and then GTM would not work anyway. Since iframes can not access JS variables of the parent website.
My new GTM approach would be:
A) fire events in PlayCanvas
B) push the event into the dataLayer in the parent website via postmessage.
Will let you know how it goes. It is still a little mysterious why the GTM code works in the editor but not when published.