Forum Discussion
Will_Findlay
4 months agoCommunity Member
Can I insert Google Analytics javascript in a trigger?
Will it work to put the code below in a trigger: "Execute JavaScript when the timeline starts on this slide?" I want to track using Google Analytics, but I don't want to edit the HTML launch file eve...
- 4 months ago
Can confirm that this works!
- Set up your Google Analytics property
- In Google Analytics go to Admin (gear icon) > Data collection and modification > Data streams
- Add a stream if needed
- Click on the stream and click "View tag instructions."
- Choose "Install manually."
- Copy the code it gives you and paste into a text editor
<!-- Google tag (gtag.js) --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-YOURGCODE"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-YOURGCODE'); </script>
7. Replace lines 2 and 3 with the actual javascript contents of the page at https://www.googletagmanager.com/gtag/js?id=G-YOURGCODE
8. Copy all of that and paste into a Javascript Trigger.
Will_Findlay
4 months agoCommunity Member
I'm getting an error about that first line - I don't think you can refer to script library apparently.