# Using GTM custom events in Piwik Pro analytics

**URL:** <https://community.piwik.pro/t/using-gtm-custom-events-in-piwik-pro-analytics/2642>\
**Category:** Data collection and tags\
**Created:** [July 26, 2023, 8:00am UTC](https://community.piwik.pro/t/using-gtm-custom-events-in-piwik-pro-analytics/2642 "2023-07-26T08:00:55Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![lookilooker](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/lookilooker/32/2167_2.png) [@lookilooker](https://community.piwik.pro/u/lookilooker)\
**Post date:** [July 26, 2023, 8:00am UTC](https://community.piwik.pro/t/using-gtm-custom-events-in-piwik-pro-analytics/2642/1 "2023-07-26T08:00:55Z")

</div>

Hello,

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.

---

<div class="post-metadata">

**Author:** ![kuba](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/kuba/32/7_2.png) [@kuba](https://community.piwik.pro/u/kuba)\
**Post date:** [July 26, 2023, 8:23am UTC](https://community.piwik.pro/t/using-gtm-custom-events-in-piwik-pro-analytics/2642/2 "2023-07-26T08:23:29Z")

</div>

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

```auto
<scrip>
    var _paq = window._paq || [];
    _paq.push(['trackEvent', 'cat', 'action', 'name', 123]);
</script>

```

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](https://github.com/mbaersch/piwikpro-template-for-gtm) (you just import the custom `template.tpl` file).

---

<div class="post-metadata">

**Author:** ![lookilooker](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/lookilooker/32/2167_2.png) [@lookilooker](https://community.piwik.pro/u/lookilooker)\
**Post date:** [July 26, 2023, 9:03am UTC](https://community.piwik.pro/t/using-gtm-custom-events-in-piwik-pro-analytics/2642/3 "2023-07-26T09:03:07Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![kuba](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/kuba/32/7_2.png) [@kuba](https://community.piwik.pro/u/kuba)\
**Post date:** [July 26, 2023, 9:07am UTC](https://community.piwik.pro/t/using-gtm-custom-events-in-piwik-pro-analytics/2642/4 "2023-07-26T09:07:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![lookilooker](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/lookilooker/32/2167_2.png) [@lookilooker](https://community.piwik.pro/u/lookilooker)\
**Post date:** [July 26, 2023, 9:22am UTC](https://community.piwik.pro/t/using-gtm-custom-events-in-piwik-pro-analytics/2642/5 "2023-07-26T09:22:34Z")

</div>

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

Example:  
Click URL starts with mailto:

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

---

<div class="post-metadata">

**Author:** ![kuba](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/kuba/32/7_2.png) [@kuba](https://community.piwik.pro/u/kuba)\
**Post date:** [July 26, 2023, 9:28am UTC](https://community.piwik.pro/t/using-gtm-custom-events-in-piwik-pro-analytics/2642/6 "2023-07-26T09:28:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![lookilooker](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/lookilooker/32/2167_2.png) [@lookilooker](https://community.piwik.pro/u/lookilooker)\
**Post date:** [July 26, 2023, 9:31am UTC](https://community.piwik.pro/t/using-gtm-custom-events-in-piwik-pro-analytics/2642/7 "2023-07-26T09:31:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kuba](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/kuba/32/7_2.png) [@kuba](https://community.piwik.pro/u/kuba)\
**Post date:** [July 26, 2023, 9:39am UTC](https://community.piwik.pro/t/using-gtm-custom-events-in-piwik-pro-analytics/2642/8 "2023-07-26T09:39:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lookilooker](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/lookilooker/32/2167_2.png) [@lookilooker](https://community.piwik.pro/u/lookilooker)\
**Post date:** [July 26, 2023, 9:40am UTC](https://community.piwik.pro/t/using-gtm-custom-events-in-piwik-pro-analytics/2642/9 "2023-07-26T09:40:57Z")

</div>

Ok thanks a lot kuba!

---

<div class="post-metadata">

**Author:** ![lookilooker](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/lookilooker/32/2167_2.png) [@lookilooker](https://community.piwik.pro/u/lookilooker)\
**Post date:** [July 26, 2023, 10:49am UTC](https://community.piwik.pro/t/using-gtm-custom-events-in-piwik-pro-analytics/2642/10 "2023-07-26T10:49:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kuba](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/kuba/32/7_2.png) [@kuba](https://community.piwik.pro/u/kuba)\
**Post date:** [July 26, 2023, 10:55am UTC](https://community.piwik.pro/t/using-gtm-custom-events-in-piwik-pro-analytics/2642/11 "2023-07-26T10:55:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lookilooker](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/lookilooker/32/2167_2.png) [@lookilooker](https://community.piwik.pro/u/lookilooker)\
**Post date:** [July 26, 2023, 11:43am UTC](https://community.piwik.pro/t/using-gtm-custom-events-in-piwik-pro-analytics/2642/12 "2023-07-26T11:43:31Z")

</div>

![image](https://europe1.discourse-cdn.com/flex005/uploads/piwikpro/original/2X/4/4f64646aec31e6a0eda1ac3590ed6a4a3b40c077.png)

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

> **[Template not compatible with the container](https://community.stape.io/t/template-not-compatible-with-the-container/118)**
>
> I downloaded the zip file from the youtube tutorial, but it says the template not compatible with the container. What seems to be the problem? Thanks in advance to those who will answer.

---

<div class="post-metadata">

**Author:** ![kuba](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/kuba/32/7_2.png) [@kuba](https://community.piwik.pro/u/kuba)\
**Post date:** [July 26, 2023, 11:48am UTC](https://community.piwik.pro/t/using-gtm-custom-events-in-piwik-pro-analytics/2642/13 "2023-07-26T11:48:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lookilooker](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/lookilooker/32/2167_2.png) [@lookilooker](https://community.piwik.pro/u/lookilooker)\
**Post date:** [July 26, 2023, 11:53am UTC](https://community.piwik.pro/t/using-gtm-custom-events-in-piwik-pro-analytics/2642/14 "2023-07-26T11:53:17Z")

</div>

Web container meaning they are on Google server.

---

<div class="post-metadata">

**Author:** ![kuba](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/kuba/32/7_2.png) [@kuba](https://community.piwik.pro/u/kuba)\
**Post date:** [July 26, 2023, 12:01pm UTC](https://community.piwik.pro/t/using-gtm-custom-events-in-piwik-pro-analytics/2642/15 "2023-07-26T12:01:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mbaersch](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/mbaersch/32/35_2.png) [@mbaersch](https://community.piwik.pro/u/mbaersch)\
**Post date:** [July 26, 2023, 12:32pm UTC](https://community.piwik.pro/t/using-gtm-custom-events-in-piwik-pro-analytics/2642/16 "2023-07-26T12:32:35Z")

</div>

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](https://tagmanager.google.com/gallery/#/owners/PiwikPRO/templates/analytics-template-for-gtm)

If it is a server-side GTM and you want to import a tag template, it would require manual import from this file here: [https://github.com/PiwikPRO/server-side-template-for-gtm/blob/master/template.tpl](https://github.com/PiwikPRO/server-side-template-for-gtm/blob/master/template.tpl)

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

---

<div class="post-metadata">

**Author:** ![lookilooker](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/lookilooker/32/2167_2.png) [@lookilooker](https://community.piwik.pro/u/lookilooker)\
**Post date:** [July 26, 2023, 12:53pm UTC](https://community.piwik.pro/t/using-gtm-custom-events-in-piwik-pro-analytics/2642/17 "2023-07-26T12:53:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kuba](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/kuba/32/7_2.png) [@kuba](https://community.piwik.pro/u/kuba)\
**Post date:** [July 26, 2023, 1:37pm UTC](https://community.piwik.pro/t/using-gtm-custom-events-in-piwik-pro-analytics/2642/18 "2023-07-26T13:37:03Z")

</div>

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