-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add matomo tracker for client side only (#236)
This will include a script from stats.data.gouv.fr, adding this information for datagouv/data.gouv.fr#1557
- Loading branch information
1 parent
ebf7d70
commit 8000c99
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export default defineNuxtPlugin((nuxtApp) => { | ||
const _paq = (window._paq = window._paq || []) | ||
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */ | ||
_paq.push(['trackPageView']) | ||
_paq.push(['enableLinkTracking']); | ||
(function () { | ||
const u = nuxtApp.$config.public.matomo_host | ||
if (u) { | ||
_paq.push(['setTrackerUrl', u + 'matomo.php']) | ||
_paq.push(['setSiteId', nuxtApp.$config.public.matomo_site_id]) | ||
const d = document, | ||
g = d.createElement('script'), | ||
s = d.getElementsByTagName('script')[0] | ||
g.async = true | ||
g.src = u + 'matomo.js' | ||
s.parentNode.insertBefore(g, s) | ||
} | ||
})() | ||
}) |