Tag Manager with React/Redux app

(vukasin) #1

Has anyone had success with implementing _mtm with SPA?

I’ve tried to find documentation which will provide more than code snipped to be put in index.html but no luck.

With tracking client is more or less clear how to proceed and it worked.

(Lukas Winkler) #2


I am not sure how MTM would work any different in a SPA than in a “regular” website.

The only thin you need to pay attention is that MTM should be initialized as early in the app as possible as it obviously can’t react to anything that happens before

(vukasin) #3

@Lukas thanks for answer.

This is very first time for me to work with Matomo so maybe I have conceptual misunderstanding of how tag manager works.

I expect that _mtm.push({event: "blahblah"}) send event data to matomo analytic server (aka issuing GET or POST request) but it just adds event to list: MatomoTagManager.dataLayer.events?

With tracking client I can programmatically send data to analytic server with _paq.push(['trackPageView']);


_mtm.push is the dataLayer and doesn’t send anything to Matomo Analytics directly. Only to the dataLayer of the Tag Manager. See Data Layer: Integrate - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v3

You would need to use _paq.push(['trackEvent', 'category', 'name', 'action']); for example.

(vukasin) #5

@thomas_matomo thanks a lot for clarification - this helps a lot.