diff --git a/docs/5.x/media-analytics/faq.md b/docs/5.x/media-analytics/faq.md index fe9824513..4dc257ad4 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` 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');`