Improve tagged events (#2880)

* allow '--' in addition to '=' in the classnames

* changelog update
pull/2884/head
RobertJoonas 4 years ago committed by GitHub
parent 8dc8423319
commit 020e155fdf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file.
## Unreleased
### Added
- Ability to use '--' instead of '=' sign in the `tagged-events` classnames
- 'Last updated X seconds ago' info to 'current visitors' tooltips
- Add support for more Bamboo adapters, i.e. `Bamboo.MailgunAdapter`, `Bamboo.MandrillAdapter`, `Bamboo.SendGridAdapter` plausible/analytics#2649
- Ability to change domain for existing site (requires numeric IDs data migration, instructions will be provided separately) UI + API (`PUT /api/v1/sites`)

@ -104,11 +104,11 @@ function getTaggedEventAttributes(htmlElement) {
for (var i = 0; i < classList.length; i++) {
var className = classList.item(i)
var matchList = className.match(/plausible-event-(.+)=(.+)/)
var matchList = className.match(/plausible-event-(.+)(=|--)(.+)/)
if (!matchList) { continue }
var key = matchList[1]
var value = matchList[2].replace(/\+/g, ' ')
var value = matchList[3].replace(/\+/g, ' ')
if (key.toLowerCase() === 'name') {
eventAttrs.name = value
@ -180,7 +180,7 @@ function isTagged(element) {
var classList = element && element.classList
if (classList) {
for (var i = 0; i < classList.length; i++) {
if (classList.item(i).match(/plausible-event-name=(.+)/)) { return true }
if (classList.item(i).match(/plausible-event-name(=|--)(.+)/)) { return true }
}
}
return false

@ -12,7 +12,7 @@
<body>
<a id="link"
class="plausible-event-name=Payment+Complete should ignore-this plausible-event-amount=100 plausible-event-method=Credit+Card"
class="plausible-event-name--Payment+Complete should ignore-this plausible-event-amount--100 plausible-event-method--Credit+Card"
href="https://awesome.website.com/payment/">tagged link</a>
<form class="plausible-event-name=Signup plausible-event-type=Newsletter"
@ -58,6 +58,7 @@
</span>
<script>
// Dynamically add a tagged element to DOM after one second
setTimeout(function () {

Loading…
Cancel
Save