Skip to content

Outlink and download tracking not working for links added after DOM ready (which many are these days eg angular, vue.js, react, ... SPA). #15780

@thibautguedou3

Description

@thibautguedou3

Hi there,

We are using Matomo on a VueJS project but we have trouble tracking outlinks.

When a user navigates from our home page to an other page inside the app and then clicks on a link that redirects him outside the app, the link does not appear as an outlink on the Matomo dashboard. However, when the user clicks on an external link directly on the home page, the outlink appears correctly on the Matomo dasboard.

You can find a very simple vue project where you can reproduce the issue: https://github.com/thibautguedou3/matomo-vue-outlink

I can reproduce the issue both on Chrome and Safari

Platform: Mac OS

Could it be a configuration issue in the matomo script ?

<script type="text/javascript">
      var _paq = window._paq || [];
      /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
      _paq.push(["trackPageView"]);
      _paq.push(["enableLinkTracking"]);
      (function() {
        var u = "MATOMO_URL";
        _paq.push(["setTrackerUrl", u + "matomo.php"]);
        _paq.push(["setSiteId", "SITE_ID"]);
        var d = document,
          g = d.createElement("script"),
          s = d.getElementsByTagName("script")[0];
        g.type = "text/javascript";
        g.async = true;
        g.defer = true;
        g.src = "//cdn.matomo.cloud/MATOMO_URL/matomo.js";
        s.parentNode.insertBefore(g, s);
      })();
    </script>

Metadata

Metadata

Assignees

Labels

BugFor errors / faults / flaws / inconsistencies etc.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions