I want to track the users of my website. Since I do not have an old fashioned HTML file, should I adapt the given code to the jade syntax or can i leave the script untouched and include it somehow?
In case I need to convert it to jade syntax, can this be auto generated by some tool.
<script> (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'); ga('create', 'UA-XXXXXXXX-X', 'domain.com'); ga('send', 'pageview'); </script>
Instead of having it look for another code file and load it. Inline (like Trevor suggested is better).
In order to accomplish this you have to make use of the script.
tag.... not just script
See below:
script. (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'); ga('create', 'UA-11111111-1', 'yourdomain.com'); ga('send', 'pageview');
Make sure the spacing and such is actually indented one tab from your stuff
The solution was easy.
Step 1: i created a file called 'analytics.js' and placed the code between the script tags in it. No conversion to jade syntax needed.
Step 2: i referenced the script from the jade file
script(src='/js/analytics.js')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With