Last active
December 10, 2015 13:18
-
-
Save jkresner/4439477 to your computer and use it in GitHub Desktop.
Running Google Analytics with Meteor js (Insert your own tracking code)
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
<head> | |
<title>Your meteor app</title> | |
</head> | |
<body> | |
{{> setup}} | |
</body> | |
<template name="setup"></template> |
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
Template.setup.rendered = -> | |
if !window._gaq? | |
window._gaq = [] | |
_gaq.push(['_setAccount', 'UA-XXXXXXXX-N']) | |
_gaq.push(['_trackPageview']) | |
(-> | |
ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; | |
gajs = '.google-analytics.com/ga.js' | |
ga.src = if 'https:' is document.location.protocol then 'https://ssl'+gajs else 'http://www'+gajs | |
s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s) | |
)() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment