Tag Manager in Nuxt Application?


does anybody know how to integrate matomo tag manager into a nuxt project/application?

The module nuxt-matomo (https://github.com/pimlie/nuxt-matomo) is just for tracking code and not for tag manager.

Has anyone experience with this?

Best regards,



No, sorry, but it seems very similar to Angular and React no? So I guess it will be all about tweaking the template to add a datalayer event when a new page is generated no?
So it is more about discussing with a Nuxt developed to make her/him add the line of code when the new page is loaded and finished, no?

The question is about how to integrate the tag manager code the right way and how to handle route changes (and also dynamic page titles) to get the right data to the tag manager.

I work on a solution but it’s very hard because I have no experience with this. So my question if heres somebody with some experiences to share.

@iparker I am looking into the same task. Did you come up with a solution?

Not in production for now, but it works pretty well so far: in my Matomo container I have a tag (e.g. Matomo Analytics) with two triggers: ‘Pageview’ - for the initial page request on the server (SSR/static site) and ‘History change’ for all further requests when nuxt switches to SPA mode.

In nuxt I have a plugin (plugins/matomo.client.js):

/* eslint-disable */

export default () => {
  // manually add the script to the DOM
  const script = document.createElement('script')

  script.innerHTML = `
    <!-- Your Matomo Tag Manager Code -->


Then add the plugin to nuxt.config.js.

I think a better and more elegant way would be to write something that triggers _mtm.push({‘event’: ‘mtm.PageView’}); everytime a route changes, but for now I’m happy to have something.