Using GTM custom events in Piwik Pro analytics


Our company has a quite long history using GA and GTM in our website. We’re now testing out Piwik Pro and we got it working by adding Piwik Pro tracking cookie tag to GTM. However we would like to continue using GTM because we have lots of custom events in there so that Piwik Pro would only serve as an analytics and report tool which tracks the GTM custom events.

How this could work? We haven’t found any proper answer to this.
Thank you in advance.

Hi. You could install analytics only using the template from gtm marketplace and set up custom events using custom code tags:

    var _paq = window._paq || [];
    _paq.push(['trackEvent', 'cat', 'action', 'name', 123]);

The other option is to use the template prepared by Markus, which allows tracking also custom events: GitHub - mbaersch/piwikpro-template-for-gtm: Piwik PRO Analytics template for Google Tag Manager (you just import the custom template.tpl file).

Thank you for your reply.

I think we have now used the official template from the gtm marketplace according to the official documentation. You mean that the existing events in gtm should be edited with these custom codes?

And Markus’ template is a different one from the official that allows using custom events? Wouldn’t this option be easier to start using the existing custom events?

Can you elaborate on the existing events in gtm? I assumed that there are some additional custom events that you would like to send to Piwik PRO directly from GTM.

Well the most basic triggering GA4 event is link click for mail address for link click for telephone.

Click URL starts with mailto:

So these would be the starting points to see the events triggering in Piwik Pro from GTM.

So I assume that you already track those as custom events in GA4? If yes, I’d create a separate tag with same triggers to send that data to Piwik PRO.

Yes you are correct. So you mean that the new tag would be Custom html with similar script you provided in the first reply?

Yes. Or the custom template created by Markus to avoid custom html tags. :slight_smile:

Ok thanks a lot kuba!

Just a heads up, tried to import the custom tpl file, but GTM says Error importing file. Strange.

What’s the error? Maybe you simply have to change the name as it may be conflicting with the standard template from the gallery.


“Error importing file”
Something to do with containter type?

Is it a client-side or server-side container?

Web container meaning they are on Google server.

I just added the template and it worked fine. @mbaersch maybe you could help?

read this thread but I am still unsure what template we are talking about and what kind of GTM container it shoud be imported to. As there are tag templates for server-side GTM and client-side GTM I guess the message is right and it is just the wrong template?

In a regular web GTM you could simply import this template that can be found in the gallery from within GTM directly: Tag Manager Template Gallery

If it is a server-side GTM and you want to import a tag template, it would require manual import from this file here:

“My” templates are both just forks of the “official” ones, so I do not know if they are really involved(?)

Yeah I think the issue could the compability issue for regular web GTM vs server-side GTM. The regular one works without issues which we searched from the GTM. This manually importing one gives error.

My goal was to use the custom web template to avoid using custom code tags to send events.