node.js - How to use google analytics from jade file -
i want track users of website. since not have old fashioned html file, should adapt given code jade syntax or can leave script untouched , include somehow?
in case need convert jade syntax, can auto generated 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 code file , load it. inline (like trevor suggested better).
in order accomplish have make use of script.
tag.... not 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 spacing , such indented 1 tab stuff
Comments
Post a Comment