Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional tracker instructions for matomoAsyncInit #704

Open
wants to merge 3 commits into
base: live
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs/5.x/media-analytics/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
1 change: 1 addition & 0 deletions docs/5.x/tracking-javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -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');`
Expand Down