From 411a0596bc4064cd787a2a20846af73d09e7abf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Belchior?= Date: Tue, 29 Mar 2016 18:45:48 +0100 Subject: [PATCH] Update google-analytics.md Was having some issues with calling "service.analytics" since I was putting it outside of globals. Updated the structure of the recipe to you first set the ID then write the partial, either in jade or ejs. --- public/recipes/google-analytics.md | 31 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/public/recipes/google-analytics.md b/public/recipes/google-analytics.md index 22ba251..06bd669 100644 --- a/public/recipes/google-analytics.md +++ b/public/recipes/google-analytics.md @@ -6,11 +6,22 @@ This recipe shows you how to add Google Analytics to your Harp application in a First, ensure you've actually created the site details in your Google Analytics account. You'll need to go to your *Property Settings* and find the *Tracking Id* value. -## Harp +### ID -### Using Jade +First, set the ID value inside globals in _harp.json or harp.json: -First, create a partial to include Google's embed code. +```json +{ + "globals": { + "service": { + "analytics": "UA-XXXX" + } + } +} +``` +Then, create a partial to include Google's embed code. + +### Using Jade _shared/analytics.jade @@ -26,19 +37,9 @@ if service.analytics ga('send', 'pageview'); ``` -Then, set the values in _harp.json or harp.json: - -```json -"service": { - "analytics": "UA-XXXX" -} -``` - ### Using EJS -First, create a partial to include Google's embed code. - -_shared/analytics.jade +_shared/analytics.ejs ```ejs <% if(service && service.analytics) { %> @@ -54,5 +55,3 @@ _shared/analytics.jade <% } %> ``` -Then create the same _harp.json or harp.json described above. -