Giter Club home page Giter Club logo

Comments (7)

kremalicious avatar kremalicious commented on May 26, 2024 1

enableLinkTracking is added by default with this plugin and I found this automatic outlink/download link tracking covering most use cases. For me, the Behavior > Outlinks & Behavior > Downloads lists in Matomo get populated as expected.

But that automatic detection is based on a pre-defined list of file extensions Matomo uses to detect download links. Are you using any other extension than in this list maybe? If so I could add an option to add more file extensions for the automatic link tracking.

7z|aac|arc|arj|apk|asf|asx|avi|bin|bz|bz2|csv|deb|dmg|doc|
exe|flv|gif|gz|gzip|hqx|jar|jpg|jpeg|js|mp2|mp3|mp4|mpg|
mpeg|mov|movie|msi|msp|odb|odf|odg|odp|ods|odt|ogg|ogv|
pdf|phps|png|ppt|qt|qtm|ra|ram|rar|rpm|sea|sit|tar|
tbz|tbz2|tgz|torrent|txt|wav|wma|wmv|wpd||xls|xml|z|zip

For full manual control you could always use the tracker object on window directly, like:

<a href="/static/somefile.zip" download onClick={() => window._paq.push(['trackLink', 'https://myurl.com/static/somefile.zip', 'download'])}>Download</a>

But that's rather cumbersome obviously

from gatsby-plugin-matomo.

kremalicious avatar kremalicious commented on May 26, 2024 1

good point @samajammin, enableLinkTracking is not added to the initial generated static page, but fired on client-side only in gatsby-browser.js for every route change on Gatsby's onRouteUpdate trigger: https://github.com/kremalicious/gatsby-plugin-matomo/blob/master/src/gatsby-browser.js#L36

I based this on somewhat of an educated guess, where I understood that for a single page application Matomo needs that so not only links on the initial page are tracked, but also on subsequent visited pages. And a user arriving on the first landing page will fire onRouteUpdate, which will then actually record the first page view hit, and enable link tracking for that route.

That being said, I never fully explored link tracking since it seemed to just work with that implementation. There's probably a case to be made, which needs to be verified and tested, to put enableLinkTracking within the initial tracking code and see how Gatsby behaves with its static and hydrated pages. So I'll keep this issue open for now in case anybody else has some experiences to share, thanks everyone so far for reporting back!

from gatsby-plugin-matomo.

samajammin avatar samajammin commented on May 26, 2024 1

Following up on this for folks who are curious.

Since migrating our site to Gatsby (& using this Matomo plugin) on 6/25, we have seen a significant jump (~2x) in outlinks:
Image 2020-07-03 at 10 59 38 AM

This would support your theory @kremalicious that link tracking should be enabled on every route change, though I'm not sure how to verify this.

from gatsby-plugin-matomo.

robinmetral avatar robinmetral commented on May 26, 2024

I think this would be covered by #2

from gatsby-plugin-matomo.

fi4sk0 avatar fi4sk0 commented on May 26, 2024

Thanks for clarifying.
I found what the problem was: The downloads were hidden inside a foldout component. After switching to "hidden" instead of not rendering, it worked.

from gatsby-plugin-matomo.

samajammin avatar samajammin commented on May 26, 2024

Thanks @kremalicious!

enableLinkTracking is added by default with this plugin

I'm curious why I can't see it in the script code.

Here's the snippet I have in a <script> tag on my old site:

        var _paq = window._paq || [];
        _paq.push(['trackPageView']);
        _paq.push(['enableLinkTracking']);
        (function() {
            ...
        })();

Inspecting the DOM in dev mode with this plugin, I'm not seeing it:

    window.dev = true
    if (window.dev === true || !(navigator.doNotTrack === '1' || window.doNotTrack === '1')) {
      window._paq = window._paq || [];
      window._paq.push(['setTrackerUrl', 'https://matomo.ethereum.org/matomo.js/matomo.php']);
      window._paq.push(['setSiteId', '4']);
      window._paq.push(['enableHeartBeatTimer']);
      window.start = new Date();
      (function() {
          ...
      }
    }
  

Is it being configured under the hood somewhere?

from gatsby-plugin-matomo.

samajammin avatar samajammin commented on May 26, 2024

Thanks for the quick response & explanation @kremalicious!

FWIW, the previous site used VuePress & the outlink tracking appeared to working when added to just the initial generated static page. Perhaps the only tracking we had was when the user landed on that given page though, so I can't verify if that's the correct approach.

I'll keep an eye on our data with this new configuration & let you know if this shows similar results or not.

from gatsby-plugin-matomo.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.