Skip to content

Commit ee335ed

Browse files
committed
chore: updated README with download details
1 parent 4b2f8e9 commit ee335ed

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

packages/ga4/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,20 @@ track({ type: 'user_signup', event: { 'epn.user_id': 12345, 'ep.user_name': 'Joh
7272
7373
**Note**: It's generally best practice (or advised) to prefix any `event` properties with `ep.` or `epn.` to ensure there are no future conflicts with official GA4 parameters. If you require GA4 to parse a parameter as a number, use the prefix `epn.`, if not, use `ep.` at the start of your object key.
7474
75+
### Download
76+
77+
Download tracking happens automatically based on whether or not an anchor's `href` or `download` attribute contains a supported file URL (see list [here](https://github.com/jahilldev/minimal-analytics/blob/main/packages/ga4/src/model.ts#L36)). If you provide downloads that are not accessible by the client, for example, behind a form submission or CSRF based system, you can apply a `download` attribute with a value of a valid link url to trigger the event.
78+
79+
For example, all of these will trigger a GA4 download event:
80+
81+
```html
82+
<a href="https://download.com/file.pdf">Download</a>
83+
<a href="https://download.com/file.pdf" download>Download</a>
84+
<button download="https://download.com/file.pdf">Download</button>
85+
<input type="submit" download="https://download.com/file.pdf" value="Download" />
86+
<input type="button" download="https://download.com/file.pdf" value="Download" />
87+
```
88+
7589
## Global
7690
7791
If you'd like the `track` function to be defined on the Window, e.g `window.track()`, you'll need to define the following property prior to loading the `@minimal-analytics/ga4` package, or script:

0 commit comments

Comments
 (0)