analytics.js: add

This commit is contained in:
Rico Sta. Cruz 2017-10-29 00:09:18 +08:00
parent 8facba27b0
commit e482109fc5
No known key found for this signature in database
GPG Key ID: CAAD38AE2962619A
2 changed files with 62 additions and 33 deletions

41
analytics.js.md Normal file
View File

@ -0,0 +1,41 @@
---
title: Google Analytics's analytics.js
category: Analytics
layout: 2017/sheet
updated: DATE
intro: |
Google Analytics's analytics.js is deprecated.
### Page view
```js
ga('create', 'UA-XXXX-Y', 'auto')
ga('create', 'UA-XXXX-Y', { userId: 'USER_ID' })
```
```js
ga('send', 'pageview')
ga('send', 'pageview', { 'dimension15': 'My custom dimension' })
```
### Events
```js
ga('send', 'event', 'button', 'click', {color: 'red'});
```
```js
ga('send', 'event', 'button', 'click', 'nav buttons', 4);
/* ^category ^action ^label ^value */
```
### Exceptions
```js
ga('send', 'exception', {
exDescription: 'DatabaseError',
exFatal: false,
appName: 'myapp',
appVersion: '0.1.2'
})
```

View File

@ -1,43 +1,31 @@
--- ---
title: Analytics title: Analytics libraries
layout: 2017/sheet
layout: 2017/sheet
--- ---
### Mixpanel ### Mixpanel
Identify: ```js
mixpanel.identify('284');
mixpanel.people.set({ $email: 'hi@gmail.com' });
mixpanel.register({ age: 28, gender: 'male' }); /* set common properties */
```
mixpanel.identify('284'); [mixpanel](./mixpanel)
mixpanel.people.set({ $email: 'hi@gmail.com' }); {: .-crosslink}
mixpanel.register({ age: 28, gender: 'male' }); /* set common properties */
Events: ### Google Analytics's analytics.js
mixpanel.track('Login success'); ```js
mixpanel.track('Search', { query: 'cheese' }); ga('create', 'UA-XXXX-Y', 'auto');
ga('create', 'UA-XXXX-Y', { userId: 'USER_ID' });
```
References: ```js
ga('send', 'pageview');
ga('send', 'pageview', { 'dimension15': 'My custom dimension' });
```
* https://mixpanel.com/help/reference/javascript [analytics.js](./analytics.js)
{: .-crosslink}
### analytics.js
ga('create', 'UA-XXXX-Y', 'auto');
ga('create', 'UA-XXXX-Y', { userId: 'USER_ID' });
ga('send', 'pageview');
ga('send', 'pageview', { 'dimension15': 'My custom dimension' });
Events:
ga('send', 'event', 'button', 'click', {color: 'red'});
ga('send', 'event', 'button', 'click', 'nav buttons', 4);
/* ^category ^action ^label ^value */
Exceptions:
ga('send', 'exception', {
exDescription: 'DatabaseError',
exFatal: false,
appName: 'myapp',
appVersion: '0.1.2'
})