Skip to content

Commit

Permalink
Event tracking Matomo : répare listener (#3514)
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineAugusti authored Oct 6, 2023
1 parent 99a2bb6 commit 3f55f2e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
6 changes: 4 additions & 2 deletions apps/transport/client/javascripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ liveSocket.connect()

// Track analytics events for DOM elements by a `data-tracking-category`.
// The event will be recorded on a click event
// See https://matomo.org/faq/reports/implement-event-tracking-with-matomo/#how-to-set-up-matomo-event-tracking-with-javascript
document.querySelectorAll('[data-tracking-category]').forEach(el => {
el.addEventListener('click', function (event) {
const name = event.dataset.trackingName || ''
window._paq.push(['trackEvent', event.dataset.trackingCategory, event.dataset.trackingAction, name])
const target = event.target
const name = target.dataset.trackingName || ''
window._paq.push(['trackEvent', target.dataset.trackingCategory, target.dataset.trackingAction, name])
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ resource_id = Map.fetch!(@conn.params, "resource_id") %>
>
<%= dgettext("resource", "Delete the resource") %>
</button>
<a href={resource_path(@conn, :form, dataset_id, resource_id)}>
<button
class="button-outline primary"
type="button"
data-tracking-category="espace_producteur"
data-tracking-action="abort_delete_update_resource"
>
<a
href={resource_path(@conn, :form, dataset_id, resource_id)}
data-tracking-category="espace_producteur"
data-tracking-action="abort_delete_update_resource"
>
<button class="button-outline primary" type="button">
<%= dgettext("resource", "Update the resource") %>
</button>
</a>
Expand Down

0 comments on commit 3f55f2e

Please sign in to comment.