Google Tag Manager: install a tracking code on its own

Installation for: Analytics

Note: If you want to use all modules in Piwik PRO, install the entire Piwik PRO container via Google Tag Manager.

If you’re using Google Tag Manager, you can easily add the Piwik PRO tracking code to your website. Just installing the tracking code will give you access to Analytics. However, if you want to unlock all the modules, like Tag Manager, Customer Data Platform and Consent Manager, you’ll need to install the entire container.

To get started, you’ll need to add your site to Piwik PRO and then set up our tag in Google Tag Manager.

In this article, we’ll walk you through this process step by step.

Add a site or app in Piwik PRO

To add a site or app in Piwik PRO, follow these steps:

  1. Log in to Piwik PRO.
  2. Go to Menu > Administration.
  3. Navigate to Sites & apps.
  4. Click Add a site or app.
  5. Type the site or app name and address and click Save.
    Site or app address (Administration)

    Note: If you want to track a few domains with the same tracking code, add their addresses.

  6. Set the time zone and currency.
    Time zone and currency (administration)

    Note: We’ll show data in reports in this time zone. We’ll use this currency for goal revenue.

Install a tracking code using Google Tag Manager

Needed permissions: Edit or higher for your container in Google Tag Manager

To install the Piwik PRO tracking code with Google Tag Manager, follow these steps:

  1. In Google Tag Manager, choose the container for your site or app.
  2. Go to Tags.
  3. Click New to add a new tag.
  4. Name your tag. Example: Piwik PRO tracking code.
  5. Click Choose a tag type to begin setup…
    Google Tag Manager: add a tag
  6. Click Discover more tags in the Community Template Gallery.
    Google Tag Manager: discover more tags
  7. Click on the search icon and type in Piwik PRO Analytics. Our tag will appear in the search results.
    Google Tag Manager: Piwik PRO Analytics tag
  8. Click Piwik PRO Analytics.
  9. Click Add to workspace.
    Google Tag Manager: add to workspace
  10. Click Add to confirm your choice.
  11. Now, set up the tag. In Instance URL, type in your Piwik PRO account address. Example: https://example.piwik.pro/.
    Google Tag Manager: Piwik PRO instance URL
  12. In Site or app ID, type in your site ID. Where to find it?
    Google Tag Manager: Piwik PRO site or app ID
  13. In Analytics domains, type in your site or app address. You’ll collect data for this site or app.
    Google Tag Manager: Piwik PRO analytics domains

    Note: If you want to track a few domains with the same tracking code, add their addresses. Separate with the enter key. No commas.

  14. In Data collection, you can set up the following options:
    • Set a user ID: If turned on, you’ll recognize visitors by their user ID. A user ID can be a visitor’s email, username or some other unique identifier. We store IDs under the dimension called user ID. You can use this dimension in custom reports, segments and filters. Read more
    • Outlinks and downloads: If turned on, you’ll count outlinks and downloads. Outlinks are links that take the visitor outside your website. Downloads are links to all kind of files on your website. You’ll see collected data under Analytics > Reports > Outlinks or Analytics > Reports > Downloads.
    • Interactions with popups and content: If turned on, you’ll count times when people see and interact with your popup or content. Impressions and interactions are counted for: (1) popups added under Tag Manager > Tags > Add a tag > Custom popup, (2) content added under Tag Manager > Tags > Add a tag > Custom content, (3) any page content you tag in your website’s code. You’ll see collected data under Analytics > Reports > Content performance. Read more
    • Count session time precisely: If turned on, you’ll measure the end of a session more accurately. Session time is the period between opening the first page and closing the last one, but it’s hard to know exactly when a visitor closes the last page. This option will send ping requests to check if a visitor is still on the last page.
    • Recognize a visitor across domains: If turned on, 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 option works only for domains that use the same tracking code and are added under Administration > Websites & apps > URLs. We add the pk_vid parameter to the page URL to pass the visitor ID between domains. Read more
    • Recognize a visitor across subdomains: If turned on, 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 option works only for subdomains that use the same tracking code. You need to pick a domain where you’ll store a cookie with the visitor ID. Read more
    • Send the traffic source to the tracker debugger: If checked, you’ll see Google Tag Manager as a traffic source in Piwik PRO > Analytics > Settings > Tracker debugger. (Available for 16.12+)
  15. In Privacy, you can set up the following options:
    • Use visitor cookies: If turned off, you won’t set visitor cookies like _pk_id.* and _pk_ses.* that are responsible for recognizing visitors and their sessions.
    • Use secure cookies: If turned on, you’ll receive information from first-party cookies over a secure connection. Only websites with the HTTPS protocol will be able to access these cookies.
    • Remove the visitor cookie at custom time: The visitor cookie (_pk_id.*) is removed after 13 months by default. You can delete it at a different time.
    • Remove the session cookie at custom time: The session cookie (_pk_ses.*) is removed after 30 minutes by default. You can delete it at a different time.
    Google Tag Manager: Piwik PRO privacy
  16. In Other options, you can set up the following options:
    • Detect JavaScript errors: If turned on, you’ll record all kinds of JavaScript errors on your website. The errors will be saved as custom events with the error type and the URL of the page where they occurred. You’ll see them under Analytics > Reports > Custom events or if you create a custom report.
    • Track page views manually: If turned on, you can use a virtual page view tag or custom JavaScript code to track page views manually.
    • Use an alternative namespace: If turned on, the tracking code won’t conflict with other tracking codes used on the website. We’ll change _paq to _ppas and Piwik to PPAS.
    Google Tag Manager: Piwik PRO other options
  17. In Triggering, click Choose a trigger to make this tag fire…
    Google Tag Manager: add a trigger
  18. Select All pages.
    Google Tag Manager: a all pages trigger
  19. Click Save.
  20. Click Submit and then click Publish to push changes to your site or app.
  21. Done! Data will appear in reports in about an hour. Data in the tracker debugger will appear instantly.

    Tip: You can also check manually to see if your tracking works.  Read more

Note: With this installation, you won’t be able to use our container for Tag Manager. This means that if you want to track custom events or custom dimensions, you will need to set them up manually using the following JS API methods: trackEvent() and setCustomDimensionValue().

Alternatively, you can use the full-stack installation for GTM, which includes a container. This will allow you to track custom events and custom dimensions using our Tag Manager.

Enterprise plan Note: If you choose to install Piwik PRO using a tag manager other than ours, we won’t be able to provide technical support for such a setup. Our aim is to deliver you the best possible service, but we can’t do that for third-party tools.

Was this article helpful?

Technical support

If you still have any questions, visit our community.
There’s always someone happy to help!

Back to help center