Skip to content

Instantly share code, notes, and snippets.

@jkresner
Last active December 10, 2015 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jkresner/4439477 to your computer and use it in GitHub Desktop.
Save jkresner/4439477 to your computer and use it in GitHub Desktop.
Running Google Analytics with Meteor js (Insert your own tracking code)
<head>
<title>Your meteor app</title>
</head>
<body>
{{> setup}}
</body>
<template name="setup"></template>
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