If you want to install only the Piwik PRO’s tracking code, not the whole container, you can use the code described below. Just remember, that you’ll be able to use only Analytics, and not Tag Manager or Consent Manager.
To install only a tracking code for Piwik PRO, follow these steps:
- Get your tracking code ready:
<script type="text/javascript"> var _paq = _paq || []; _paq.push(["trackPageView"]); _paq.push(["enableLinkTracking"]); (function() { var u = "https://your-account-name.piwik.pro/"; _paq.push(["setTrackerUrl", u + "ppms.php"]); _paq.push(["setSiteId", "XXX-XXX-XXX-XXX-XXX"]); var d = document, g = d.createElement("script"), s = d.getElementsByTagName("script")[0]; g.type = "text/javascript"; g.async = true; g.defer = true; g.src = u + "ppms.js"; s.parentNode.insertBefore(g, s); })(); </script>
In this code, change the following elements:
- https://your-account-name.piwik.pro: The address you use to log in to Piwik PRO.
- XXX-XXX-XXX-XXX-XXX: The ID of the site or app in Piwik PRO where you want to send data. (Where to find it?)
- Paste the code right after the opening
<body>
tag on every page of your website or app. - Data will appear in reports in about an hour. Data in the tracker debugger will appear instantly.
Tip: You can also check manually if the tracking works. Read more
Optional settings
Some settings are controlled on the tracking-code level only, for some you’ll find settings in Piwik PRO’s UI. Here’s a quick rundown of the most common settings.
Controlled in Piwik PRO’s UI
Setting | Where |
---|---|
Basic info | |
Time zone | Administration > Sites & apps > Data collection > Time zone |
Currency | Administration > Sites & apps > Data collection > Currency |
Internal search engine | |
Keywords from your internal search engine |
Administration > Sites & apps > Data collection > Keywords from your internal search engine Administration > Settings > Global site & app settings > Data collection > Keywords from your internal search engine |
Remove keyword parameters from page URLs |
Administration > Sites & apps > Data collection > Remove keyword parameters from page URLs Administration > Settings > Global site & app settings > Data collection > Remove keyword parameters from page URLs |
Page URLs | |
Remove parameters from page URLs |
Administration > Sites & apps > Data collection > Remove parameters from page URLs Administration > Settings > Global site & app settings > Data collection > Remove parameters from page URLs |
Keep anchors in page URLs |
Administration > Sites & apps > Data collection > Keep anchors in page URLs Administration > Settings > Global site & app settings > Data collection > Keep anchors in page URLs |
Campaigns | |
Campaign parameters |
Administration > Sites & apps > Data collection > Campaign parameters Administration > Settings > Global site & app settings > Data collection > Campaign parameters |
Start a new session when the campaign changes |
Administration > Sites & apps > Data collection > Start a new session when the campaign changes Administration > Settings > Global site & app settings > Data collection > Start a new session when the campaign changes |
Filters | |
Don’t collect data from these IP addresses |
Administration > Sites & apps > Data collection > Don’t collect data from these IP addresses Administration > Settings > Global site & app settings > Data collection > Don’t collect data from these IP addresses |
Don’t collect data from known crawlers |
Administration > Sites & apps > Data collection > Don’t collect data from known crawlers Administration > Settings > Global site & app settings > Data collection > Don’t collect data from known crawlers |
Add crawlers |
Administration > Sites & apps > Data collection > Add crawlers Administration > Settings > Global site & app settings > Data collection > Add crawlers |
Collect data only from known sites |
Administration > Sites & apps > Data collection > Collect data only from known sites Administration > Settings > Global site & app settings > Data collection > Collect data only from known sites |
Other options | |
Start a new session when the referrer changes |
Administration > Sites & apps > Data collection > Start a new session when the referrer changes Administration > Settings > Global site & app settings > Data collection > Start a new session when the referrer changes |
Controlled on the tracking-code level
Method | Description |
---|---|
enableCookies() | Enables setting visitor cookies like like _pk_id.* and _pk_ses.* that are responsible for recognizing visitors and their sessions. |
disableCookies() | Disables setting visitor cookies like like _pk_id.* and _pk_ses.* that are responsible for recognizing visitors and their sessions. |
setUserIsAnonymous() | Marks a visitor as anonymous or non-anonymous. An anonymous visitor has a hidden IP address (Example: 0.0.0.0) and hidden location data (only Country data is available). |
deanonymizeUser() | Turns an anonymous visitor to non-anonymous. Enriches session data with a visitor’s IP address and location data. |
setDomains() |
Sets a list of domains that are tracked as one site or app. Use the same tracking code for these domains. Listed domains are not treated as outlinks. Listed domains get the pk_vid parameter to pass the visitor ID between them when you use enableCrossDomainLinking(). Note: For the links that are added dynamically, you need to call enableLinkTracking() each time. |
enableCrossDomainLinking() |
Enables recognizing a visitor across domains. The visitor who goes from one website to the other will be recognized as the same visitor. Sessions that would be treated as separate for each website, will be treated as one session. This method needs to be preceded with setDomains(). |
setCookieDomain() |
Sets a domain where you’ll store a cookie with the visitor ID. Used to recognize a visitor across subdomains. The visitor who goes from one subdomain to the other will be recognized as the same visitor. Sessions that would be treated as separate for each subdomain, will be treated as one session. This method needs to be preceded with setDomains(). |
setSessionIdStrictPrivacyMode() | Enables or disables reading screen resolution and browser plugins from visitor’s device without consent. Accessing a visitor’s device is not compliant with the German Data Protection Act (TTDSG) and similar privacy laws |
For more, see the developer documentation. |
Examples:
To recognize a visitor across two domains example.com
and example-two.com
:
// Set the domains that are tracked as one site or app. Use the same tracking code for these domains.
_paq.push(["setDomains", ["example.com", "example-two.com"]]);
// Enable recognizing a visitor across domains.
_paq.push(["enableCrossDomainLinking"]);
To recognize a visitor across two subdomains example.com
and help.example.com
:
// Set the domains that are tracked as one site or app. Use the same tracking code for these domains.
_paq.push(["setDomains", ["example.com", "help.example.com"]]);
// Store a cookie with the visitor ID on this domain. Use it for recognizing a visitor across subdomains.
_paq.push(["setCookieDomain", "*.example.com"]);