You need to sign in to do that
Don't have an account?
Vipin P
Google Analytics in Lightning component
We are trying to put GA code inside lightining component. I added the analytics js as static resource:
Any one have any idea on how to fix it ?
<ltng:require scripts="/resource/ga/analytics.js" afterScriptsLoaded="{!c.loadGoogleAnalytics}" />and in the controller I used this satic resource ( /resource/ga/analytics.js ) :
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) }) (window,document,'script','/resource/ga/analytics.js','ga');For some reason the last line ( (window,document,'script','/resource/ga/analytics.js','ga'); ) is not working I get the following Error :
[Cannot read property 'insertBefore' of undefined]I tried with the actaul URL ( //www.google-analytics.com/analytics.js ) as well but throws the same error.
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) }) (window,document,'script','//www.google-analytics.com/analytics.js','ga');
Any one have any idea on how to fix it ?
but no luck