Commit Graph

49 Commits (5dc9d0fb33636a221e8aab06afccd63e2cb11149)

Author SHA1 Message Date
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.
4 years ago
RobertJoonas c0da024b23
Remove static tracker files (#2116)
* remove tracker files from git index

* generate tracker files on npm test

* generate tracker files for elixir tests/dev/CI

* update tracker/package-lock.json

* exclude npm run deploy from mix test + some docs
4 years ago
RobertJoonas f75d5106f0
Rework outbound links and file downloads (#2208)
* moved custom event code to the bottom + fix indentation

* add handlebars helper fn + extract getLinkEl fn

* extract isOutboundLink function

* extract shouldFollowLink function

* remove middle and click variables

* use only one click handler for outbounds and downloads

* extract sendLinkClickEvent function

* add error handling when script compilation fails

* use callback instead of fixed timeout

* do not prevent default if externally prevented + test

* add more tests

* generate tracker files in priv/tracker/js

* update changelog

* requested changes after review

* regenerate tracker files

* use return instead of else if

* move middleMouseButton outside the function
4 years ago
RobertJoonas 39ce850f18
exclude pages by hash when using `script.exclusions.hash.js` (#2172)
* account for hash part of the URL when excluding pages and using hash extension

* changelog update
4 years ago
Uku Taht 99fd101135
Add basic test harness for browserstack/playwright (#1961)
* Add basic test harness for browserstack/playwright

* Refactor the tests

* added the first test for outbound links

* tests for outbound-links and file-downloads

* added more browser versions to test on

* Lint tracker test files

* Update harness.js with BrowserStack example

* Fix Playwright request mocks

* Add test harness to CI

* Remove Safari on Windows from browsers list

Co-authored-by: Robert <robertjoonas16@gmail.com>
Co-authored-by: Vinicius Brasil <vini@hey.com>
4 years ago
RobertJoonas 11654ddc07
Script extension additions (#1915)
* added data-include attribute to plausible.exclusions.js

* reorder extensions in filename when serving the plausible script

* fix formatting

* tweaks after review

* changelog update
5 years ago
RobertJoonas 199206babc
Dimensions continued (#1847)
* added the first version of dimensions extension

* finished dimensions script extension + updated tracking to use it

* script variants build
5 years ago
RobertJoonas 83ab092f6c
added add-file-types attribute + now ignores query params (#1831)
* added add-file-types attribute + now ignores query params

* variable extraction + adjustments to general code style
5 years ago
RobertJoonas 8616dd46fb
added file-downloads script extension (#1775)
* added file-downloads script extension

* fixed the issues and made it compatible with IE

* changelog update
5 years ago
dependabot[bot] 0dbfb7b70a
Bump minimist from 1.2.5 to 1.2.6 in /tracker (#1793)
Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
5 years ago
Uku Taht 045268f080 Remove console log 5 years ago
Uku Taht e4b99dbad6
Fix Security error with localstorage access (#1568)
* Fix Security error with localstorage access

* Changelog
5 years ago
Émile Perron fbd6e37767
Add option to specify a URL in the manual extension (#1479)
* Add option to specify a URL in the manual extension

* Fix error when option parameter isn't provided
The uglify-js dependency had to be updated to support the optional chaining operator

* Remove the possibility to pass a function for the custom URL
This added weight unnecessarily, as the users can simply call the function themselves before triggering the event.

* Change optional chaining to ternary for improved browser support

* Revert package-lock.json to version 3.9.4 of uglify-js
It was previously updated to support optional chaining; reverting it as a reminder that this is the current browser support level that is accepted by Plausible.
5 years ago
Uku Taht 086d4de74e Remove window.phantom from automated browser detection
Fixes #1403
5 years ago
Uku Taht 23a4f37ab4 Add 'manual' script variant 5 years ago
Uku Taht a7eab3f17b Add null check to localstorage access
Fixes #1225
5 years ago
Uku Taht 62c5bfcbf8 Use unless instead of if 5 years ago
Martin DONADIEU 56b485f2e6
feat: add variant local (#1218)
* Update plausible.js

* feat: add new variant

* feat: add allow-localhost

* Update tracker.ex

* Update compile.js

* Update plausible.js

* Update tracker.ex

* Update compile.js

* Update plausible.js
5 years ago
Martin Packman f5b412b4c8
Fix IPv6 localhost detection in tracker script (#1200)
IPv6 literals in url hostnames follow RFC 2732 so are enclosed in
brackets.

Browsers normalise so matching zeros is not required.

Allow `::` unspecified address as well as `::1`  loopback address.

Non-capturing groups not required when using `/.../.test()` method.
5 years ago
Uku Taht 7c9ca12a3e Don't use URL in compat mode 5 years ago
Uku Taht a378935aac Add IE11 compatibility mode 5 years ago
Uku Taht 2be99db54d Fix p.js 6 years ago
Uku Taht ff9f95ea18 Fix old script 6 years ago
Uku Taht e80fc7bb8e
Tracker script improvements (#1048)
* Use `document.currentScript` to get script host

* Add data-api
6 years ago
Vignesh Joglekar 7f3e55418b
Changes from static tracker script name assignments to dynamic (#786)
Co-authored-by: Uku Taht <Uku.taht@gmail.com>
6 years ago
dependabot[bot] 1d53648896
Bump handlebars from 4.7.6 to 4.7.7 in /tracker (#1008)
Bumps [handlebars](https://github.com/wycats/handlebars.js) from 4.7.6 to 4.7.7.
- [Release notes](https://github.com/wycats/handlebars.js/releases)
- [Changelog](https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md)
- [Commits](https://github.com/wycats/handlebars.js/compare/v4.7.6...v4.7.7)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
6 years ago
Vignesh Joglekar 96633f46b1
Fixes exclude regex eating one character before single * (#861)
* Swaps to Negative Lookbehind for exclude Regex

* Updates to not use negative lookbehind
6 years ago
Iiro Krankka dde5116a76
Stop analytics tracking if running under Cypress tests (#850)
* Stop tracking if running under Cypress tests

* Update CHANGELOG.md
6 years ago
Vignesh Joglekar fb7a3fef89
Adds data-exclude support and localStorage.plausible_ignore support (#489)
* Adds data-exclude support and plausible_ignore support

* Splits exclusion into separate script option

* localStorage parsing upgrades

* Additional script type additions

I'm unsure about the formatting decision in tracker.ex - lmk.

* Adds new compiled files

This will certainly have conflicts with my other PRs related to the tracking scripts right now, I'll make one extra PR after both are done to ensure they're consolidated into the compiled scripts.

* Moves localStorage blocker out of special script

* Changelog

* Second thoughts on localStorage exclusion

* Updates `*` to not match `/` or whitespace

* Fix formatting

* Removes zero-length asterisks

* Adds support for double glob, zero-length replacements

* Update to reduce size+allow localStorage exclude

Co-authored-by: Uku Taht <Uku.taht@gmail.com>
6 years ago
Uku Taht 873fe1a337 Add note about p.js 6 years ago
Vignesh Joglekar 31ed9c017c
Allows middle-click and ctrl+click outbound clicks to properly open as user intended (#494)
* Initial fix

* Filesize optimizations

* Changelog

* Only redirects current tab on correct conditions

Does nothing special on middle or mod-click
6 years ago
Uku Taht 719b67ed22 Add nodejs to .tool-versions 6 years ago
Uku Taht b724def948 Only register outbound link click if it has a host property
Fixes #398
6 years ago
Uku Taht 392b0b33ee Make outbound link tracking dynamic 6 years ago
Uku Taht 0a530a0f66 Do not use pushState and popState in hash mode 6 years ago
Uku Taht 1b21a26e78 Ignore hash clicks 6 years ago
Uku Taht d0d7b823f8
Browser and OS version (#397)
* Collect browser and OS version

* Display browser version

* Show operating system versions

* Device categorization

* Treat headless chrome like a bot

* Ignore events from automated browsers

* Only take major and minor of the version

* Add tests

* Add CHANGELOG entry

* Add changelog entry for bots

* Store empty value as browser when unknown
6 years ago
Gustavo Maronato 77ec529f19
Fix #401 (#402) 6 years ago
Uku Taht f0cbf33d7c
Add tracker feature to automatically track outbound links (#389)
* Add tracker feature to automatically track outbound links

* Precompute templates and allow aliases

* Fix /js/analytics.js

* Remove change to tracking code

* Update CHANGELOG
6 years ago
Uku Taht 0b6e645b44
Rename metadata -> properties (#390) 6 years ago
Uku Taht 40900c7653
Ability to add event metadata (#381)
* Ability to add event metadata

* Close Dropdown on outside click

* Show (none) value in metadata breakdown

* Allow filtering for metadata key/val pairs

* Use correct clickhouse_ecto

* Better naming for meta filter

* Add tests

* Add changelog entry

* Remove change made for testing
6 years ago
Uku Taht b2f78bb741
Change Javascript license to MIT (#369) 6 years ago
Uku Taht 3a99b8a4fb
Handle page visibility change when preloading (#311) 6 years ago
Uku Taht 4aa4dfdcaf
Hash mode (#299)
* Build tracker with hash mode

* Extract hash fragment in hash mode

* Serve new hash-based tracker
6 years ago
Uku Taht d30f17c807
Extract utm_source on the server side (#298)
* Extract utm_source on the server side

* Build tracker scripts
6 years ago
Uku Taht 1519359bbf
Makes the tracker and its payload smaller (#296) 6 years ago
Uku Taht bb36bae15c
Inject base url to tracker at runtime (#78)
* Inject base url to tracker at runtime

* Cache tracker script for 1 hour
7 years ago
Uku Taht 8d36d27ca3 Default script to prod 7 years ago
Uku Taht 4bd12f03fc
Reduce script size (#68)
* Remove cookie code

* Compile tracker separetly from website assets

* Install uglify

* Help minifier reduce varaibles
7 years ago