analytics/tracker/test
RobertJoonas 135471c32e
Add tagged-events script extension (#2333)
Adds a new script extension that allows tracking interactions with specific HTML elements on a website. For example - to track link clicks on one specific `<a>` element, you can tag it like this:

```html
<a href=... class="plausible-event-name=<your_event_name>">
```

And you can also tag the link with custom property names and values:

```html
<a href=... class="plausible-event-name=<your_event_name> plausible-event-<your_custom_prop>=<your_value>">
```

Tagging a link as above will send a custom event with the given name and props, if a `click` or `auxclick` browser event happens, and targets the link element.

The tracking behavior is somewhat different based on the HTML element type:  

- `<a>` 
  - triggers on `click` and `auxclick` events
  - intercepts navigation based on the same rules as `outbound-links` and `file-downloads`
- `<form>`
  - triggers on `submit` event
  - always intercepts navigation (calls `form.submit()` after preventing default and sending the Plausible event)
- other (`<img>`, `<button>`, `<span>`, `<div>`, `<h2>`, etc ...)
  - triggers on `click` and `auxclick` events
  - does not prevent default to intercept possible navigation. Simply calls Plausible with the event name and props read from the element class list.
2022-11-21 16:17:44 +02:00
..
fixtures Add tagged-events script extension (#2333) 2022-11-21 16:17:44 +02:00
support Rework outbound links and file downloads (#2208) 2022-09-29 14:12:35 +03:00
custom-event-edge-cases.spec.js Add tagged-events script extension (#2333) 2022-11-21 16:17:44 +02:00
file-downloads.spec.js Rework outbound links and file downloads (#2208) 2022-09-29 14:12:35 +03:00
hash-exclusions.spec.js exclude pages by hash when using script.exclusions.hash.js (#2172) 2022-09-07 16:41:08 +03:00
outbound-links.spec.js Rework outbound links and file downloads (#2208) 2022-09-29 14:12:35 +03:00
pageview.spec.js Add basic test harness for browserstack/playwright (#1961) 2022-08-04 11:50:09 +03:00
tagged-events.spec.js Add tagged-events script extension (#2333) 2022-11-21 16:17:44 +02:00