Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update google-analytics.md #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 15 additions & 16 deletions public/recipes/google-analytics.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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) { %>
Expand All @@ -54,5 +55,3 @@ _shared/analytics.jade
</script>
<% } %>
```
Then create the same _harp.json or harp.json described above.