Last active
November 26, 2019 18:44
-
-
Save antlis/56cd3963182ebaeadec55a23efbb60f9 to your computer and use it in GitHub Desktop.
Google analytics pug mixin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mixin ga(id) | |
//- Pass your ga id, as an attribute, eg. +ga('yourid12345') | |
script. | |
(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]= | |
function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date; | |
e=o.createElement(i);r=o.getElementsByTagName(i)[0]; | |
e.src='https://www.google-analytics.com/analytics.js'; | |
r.parentNode.insertBefore(e,r)}(window,document,'script','ga')); | |
ga('create', !{id});ga('send','pageview'); |
For any others that are newbie like me, here is a way to apply it in .pug file:
include your_path/ga.pug +ga
The first one to import it and the second line to active it.
Hi, I updated it, now you can pass your id as an attribute to mixin, +ga('yourid12345')
Also here is pug google analytics mixin, that will output script like you can find in HTML5 boilerplate.
Also here is pug google analytics mixin, that will output script like you can find in HTML5 boilerplate.
That makes the code more flexible, thanks a lot! :D
Also here is pug google analytics mixin, that will output script like you can find in HTML5 boilerplate.
That makes the code more flexible, thanks a lot! :D
No problem
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For any others that are newbie like me, here is a way to apply it in .pug file:
The first one to import it and the second line to active it.