From aa9d3f7021b00579a48198d3e31821a3617e375c Mon Sep 17 00:00:00 2001 From: Joshua Date: Tue, 7 Mar 2023 15:44:19 +1300 Subject: [PATCH 1/3] Details for using additional trackers outside of the Added details for sending events to additional trackers from outside of the matomoAsyncInit function. --- docs/5.x/media-analytics/faq.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/5.x/media-analytics/faq.md b/docs/5.x/media-analytics/faq.md index fe9824513..5623407c0 100644 --- a/docs/5.x/media-analytics/faq.md +++ b/docs/5.x/media-analytics/faq.md @@ -103,6 +103,20 @@ window.matomoAsyncInit = function () { It is important to define these methods before the Piwik tracker file is loaded. Otherwise, your `matomoAsyncInit` or `matomoMediaAnalyticsAsyncInit` method will never be called. +In order to use your additional tracker(s) outside the `matomoAsyncInit` function, you will need to declare the tracker name as a Global variable. For example: + +```js + var matomoTracker1; + window.matomoAsyncInit = function () { + matomoTracker1 = Matomo.getTracker('https://example.com/matomo.php', 1); + } +``` +This will then allow the added tracker to be used for tracking events, such as link clicks: + +```js +onclick="matomoTracker1.trackEvent('Test Events', 'Click', 'Clicked X', 0);" +``` + ## Is it possible to not use the "paq.push" methods and instead call the MediaAnalytics tracker methods directly? Yes. To initialize the Media tracker you need to define a callback method `window.matomoMediaAnalyticsAsyncInit` From 020f06b32f6f3311b8347e5ea98607d00af58737 Mon Sep 17 00:00:00 2001 From: Joshua Date: Fri, 16 Aug 2024 13:19:13 +1200 Subject: [PATCH 2/3] Added hasCookies() method to tracking-javascript.md --- docs/5.x/tracking-javascript.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/5.x/tracking-javascript.md b/docs/5.x/tracking-javascript.md index 59ee85f8b..eb71e146a 100644 --- a/docs/5.x/tracking-javascript.md +++ b/docs/5.x/tracking-javascript.md @@ -143,6 +143,7 @@ Piwik uses first party cookies to keep track of some user information over time. * `disableCookies()` - Disable all first party cookies. Existing Piwik cookies for this websites will be deleted on the next page view. Cookies will be even disabled if the user has given cookie consent using the method `rememberCookieConsentGiven()`. * `deleteCookies()` - Delete the tracking cookies currently currently set (this is useful when [creating new visits](https://matomo.org/faq/how-to/#faq_187)) +* `hasConsent()` - Returns true if tracking is enabled for the visitor (regardless of cookie consent), false if tracking is disbaled for the visitor via `forgetConsentGiven()` or another method. * `hasCookies()` - Return whether cookies are enabled and supported by this browser. * `setCookieNamePrefix( prefix )` - the default prefix is '_pk_'. * `setCookieDomain( domain )` - the default is the document domain; if your website can be visited at both www.example.com and example.com, you would use: `tracker.setCookieDomain('.example.com');` or `tracker.setCookieDomain('*.example.com');` From feac9dd6b662c5f8ef081a76cd579bf733528711 Mon Sep 17 00:00:00 2001 From: Joshua Date: Fri, 16 Aug 2024 21:49:16 +1200 Subject: [PATCH 3/3] Update docs/5.x/media-analytics/faq.md Co-authored-by: Michal Kleiner --- docs/5.x/media-analytics/faq.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/5.x/media-analytics/faq.md b/docs/5.x/media-analytics/faq.md index 5623407c0..4dc257ad4 100644 --- a/docs/5.x/media-analytics/faq.md +++ b/docs/5.x/media-analytics/faq.md @@ -103,7 +103,7 @@ window.matomoAsyncInit = function () { It is important to define these methods before the Piwik tracker file is loaded. Otherwise, your `matomoAsyncInit` or `matomoMediaAnalyticsAsyncInit` method will never be called. -In order to use your additional tracker(s) outside the `matomoAsyncInit` function, you will need to declare the tracker name as a Global variable. For example: +In order to use your additional tracker(s) outside the `matomoAsyncInit` function, you will need to declare the tracker name as a global variable. For example: ```js var matomoTracker1;