node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org ยป



A Google Analytics plugin for pop, a static site generator for node.js


Install from npm

npm install -g pop-ga

Then add it as a dependency to your pop site. In your _config.json file add

, "require": ["pop-ga"]

Your _config.json file might look something like this

{  "url": ""
 , "title": "Your Site"
 , "permalink": "/:title"
 , "perPage": 10
 , "exclude": ["\\.swp"]
 , "require": ["pop-ga"]
 , "autoGenerate": [{"feed": "feed.xml", "rss": "feed.rss"}] }


To use the plugin you need the Web Property ID for your site from Google Analytics. You get this from the Google Analytics web console. I'm assuming you know the score.

Then add the following code to your jade template


Your template might look something like

!!! 5
    title #{post.title}
    link(href="/stylesheets/screen.css", media="screen", rel="stylesheet", type="text/css")
    link(rel="alternate", type="application/rss+xml", title="RSS 2.0", href="/feed.rss")
    link(rel="alternate", type="application/atom+xml", title="Atom Feed", href="/feed.xml")

The plugin will generate the default Google Analytics code for you.