Skip to content

Commit

Permalink
chore: improve readme structure
Browse files Browse the repository at this point in the history
  • Loading branch information
martinbroos committed Mar 15, 2024
1 parent bf195c1 commit 2a51d45
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 79 deletions.
15 changes: 15 additions & 0 deletions doc/gtag_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,18 @@ const App = () => {
);
};
```


## Usage

```js
import {
EventTypes,
pushGaEvent,
} from '@freshheads/analytics-essentials';

pushGaEvent({
type: EventTypes.CLICK,
name: 'hero_button_click'
});
```
4 changes: 0 additions & 4 deletions doc/mixpanel_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
This implementation of mixpanel relies on a backend service to send the data to mixpanel. The goal of the frontend lib is to provide a typechecked event to help developers push events the same way.
For the backend Freshheads created a php bundle, [FHMixpanelBundle](https://github.com/freshheads/FHMixpanelBundle) and a node library will also be created in the future.

## Installation

`npm install @freshheads/analytics-essentials`

## Usage

Add the MixpanelProvider to your app:
Expand Down
28 changes: 28 additions & 0 deletions doc/tagmanager_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,31 @@ const App = () => {
);
};
```

## Usage

```js
import {
EventTypes,
pushDataLayerEvent,
} from '@freshheads/analytics-essentials';

pushDataLayerEvent({
type: EventTypes.CLICK,
name: 'hero_button_click',
});
```

## Optional params

```js
pushDataLayerEvent({
type: EventTypes.CLICK,
name: 'hero_button_click',
context: {
// context is typed based on type
// you can always extend context with your custom properties
}
}),

```
48 changes: 19 additions & 29 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,8 @@
"next": {
"optional": true
}
},
"dependencies": {
"@freshheads/analytics-essentials": "^0.0.4"
}
}
48 changes: 2 additions & 46 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,52 +8,8 @@
npm i @freshheads/analytics-essentials
```

### Setup Google Tag or Google Tagmanager
### Usage by analytics provider

- [Mixpanel Setup](doc/mixpanel_setup.md)
- [Gtag Setup](doc/gtag_setup.md)
- [Tagmanager Setup](doc/tagmanager_setup.md)


## Usage

### With gtag

```js
import {
EventTypes,
pushGaEvent,
} from '@freshheads/analytics-essentials';

pushGaEvent({
type: EventTypes.CLICK,
name: 'hero_button_click'
});
```

### With Tag Manager

```js
import {
EventTypes,
pushDataLayerEvent,
} from '@freshheads/analytics-essentials';

pushDataLayerEvent({
type: EventTypes.CLICK,
name: 'hero_button_click',
});
```

## Optional params

```js
pushDataLayerEvent({
type: EventTypes.CLICK,
name: 'hero_button_click',
context: {
// context is typed based on type
// you can always extend context with your custom properties
}
}),

```

0 comments on commit 2a51d45

Please sign in to comment.