-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #294 from ngx-rocket/feature/analytics
Add support for analytics with Angulartics2.
Showing
17 changed files
with
210 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Analytics | ||
<% if (!props.angulartics) { -%> | ||
|
||
This project does not come with any analytics library. | ||
Should you decide to use one, you may want to consider [Angulartics2](https://github.com/angulartics/angulartics2). | ||
|
||
<% } else { -%> | ||
|
||
Analytics in this app are managed through the [Angulartics2](https://github.com/angulartics/angulartics2) library. | ||
|
||
It is already pre-configured to track page views, and provides examples to track events from both TypeScript code and HTML elements. | ||
Here is a quick usage documentation, you can read further information on the official website. | ||
|
||
## Registering your provider | ||
<% if (props.analyticsProvider === 'ga') { -%> | ||
|
||
Google Analytics is already registered as the project's analytics provider. | ||
Should you need to change the account identifier, you can do so in the call to `ga(...)` performed in the body of `index.html`. | ||
|
||
<% } else { -%> | ||
|
||
Currently, only Google Analytics is fully installed from the starter kit. | ||
Do not worry, this only means you will need to select and import your provider yourself. | ||
Simply follow the instructions detailed in the [official documentation](https://github.com/angulartics/angulartics2#supported-providers). | ||
|
||
<% } -%> | ||
## Tracking events | ||
|
||
### Declarative event tracking | ||
|
||
The simplest way to do event tracking is by adding the attributes `angulartics2On`, `angularticsCategory` and `angularticsAction` to an HTML element. | ||
The homepage generated by the starter kit contains one such button. | ||
For reference, here is a UI-framework-agnostic example. | ||
|
||
```html | ||
<button | ||
angulartics2On="click" | ||
angularticsAction="Button clicked" | ||
[angularticsCategory]="quote"> | ||
Click me to send the current quote as an Analytics event | ||
</button> | ||
``` | ||
|
||
### Using the API | ||
<% if (props.analyticsProvider === 'ga') { -%> | ||
|
||
As an example, the application already comes configured to track its startup through an event. | ||
You may use the example as reference: it can be found in the first lines of `ngOnInit()` in `app.component.ts`. | ||
|
||
<% } -%> | ||
To access the API, inject your provider : | ||
|
||
```typescript | ||
constructor(... | ||
private angulartics2GoogleAnalytics: Angulartics2GoogleAnalytics, | ||
...) | ||
``` | ||
|
||
You may then use the `eventTrack` function: | ||
|
||
```typescript | ||
this.angulartics2GoogleAnalytics.eventTrack('Something happened', {category: 'My category'}); | ||
this.angulartics2GoogleAnalytics.eventTrack('Something else happened', {category: 'My other category', label: 'My custom label'}); | ||
``` | ||
|
||
<% } -%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,6 @@ | |
"pwa": false, | ||
"ui": "ionic", | ||
"auth": false, | ||
"lazy": false | ||
"lazy": false, | ||
"angulartics": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,6 @@ | |
"layout": "simple", | ||
"auth": false, | ||
"lazy": false, | ||
"angulartics": false, | ||
"location": "hash" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters