mirror of
https://github.com/plausible/analytics.git
synced 2024-12-24 01:54:34 +03:00
135471c32e
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.
22 lines
687 B
HTML
22 lines
687 B
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
<title>Plausible Playwright tests</title>
|
|
|
|
<script defer src="/tracker/js/plausible.file-downloads.local.manual.outbound-links.tagged-events.js"></script>
|
|
</head>
|
|
|
|
<body>
|
|
<a id="outbound-download-link" href="https://awesome.website.com/file.pdf">Outbound Download</a>
|
|
|
|
<a id="local-download" href="file.csv">Local download</a>
|
|
|
|
<a id="tagged-outbound-download-link" class="plausible-event-name=Foo" href="https://awesome.website.com/file.pdf">Outbound Download</a>
|
|
</body>
|
|
|
|
</html>
|