Skip to content

Commit

Permalink
Add google tag
Browse files Browse the repository at this point in the history
  • Loading branch information
trodrigues committed Apr 29, 2016
1 parent 395a4c1 commit 45f9ae0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions bin/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ cp -r *.svg *.css *.js pages $PAGES_DIR

# Setup base path and analytics tag
cat index.html | \
./bin/setup_analytics | \
sed -e 's/<base href="\/"/<base href="\/product-catalogue-js\/"/g' > \
$PAGES_DIR/index.html

Expand Down
24 changes: 24 additions & 0 deletions bin/setup_analytics
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env node
var buffer = ''

process.stdin.setEncoding('utf8');

process.stdin.on('readable', () => {
var chunk = process.stdin.read();
if (chunk !== null) {
buffer += chunk
}
});

process.stdin.on('end', () => {
process.stdout.write(buffer.replace('<!--ANALYTICS-->', `
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-PJ5RQ2"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-PJ5RQ2');</script>
`));

});
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@
<script>
PC.init()
</script>
<!--ANALYTICS-->
</body>
</html>

0 comments on commit 45f9ae0

Please sign in to comment.