matomo-org / matomo

Empowering People Ethically with the leading open source alternative to Google Analytics that gives you full control over your data. Matomo lets you easily collect data from websites & apps and visualise this data and extract insights. Privacy is built-in. Liberating Web Analytics. Star us on Github? +1. And we love Pull Requests!
https://matomo.org/
GNU General Public License v3.0
19.9k stars 2.65k forks source link

[Bug] double metric _paq.push(['trackSiteSearch', false, false]) #22150

Closed KevinTessier closed 6 months ago

KevinTessier commented 6 months ago

What happened?

Hello,

I integrated this for a search form that offers article suggestions.

but I noticed that the data is counted twice.

Here is the integration of the code in the head:

  <script>
    var _paq = window._paq = window._paq || [];
    /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
    _paq.push(["setExcludedQueryParams", ["sp_con"]]);
    _paq.push(['enableLinkTracking']);
    (function() {
      var u="mywebsite";
      _paq.push(['setTrackerUrl', u+'matomo.php']);
      _paq.push(['setSiteId', 'VarSiteID']);
      var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
    })();
  </script>

  <script>
    var _mtm = window._mtm = window._mtm || [];
    _mtm.push({'mtm.startTime': (new Date().getTime()), 'event': 'mtm.Start'});
    (function() {
      var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
      g.async=true; g.src='mywebsite/js/container_999999999.js'; s.parentNode.insertBefore(g,s);
    })();
  </script>

and here my network :

Screenshot_20240422_183639

I suppose it's because of the two scripts in my head but I seem to need both for the ex siteID config etc..

and the second for the container.

I'm lost, if anyone has an explanation.

Best.

What should happen?

I would like to receive my research data only once.

How can this be reproduced?

i don't know

Matomo version

5.0.2

PHP version

No response

Server operating system

No response

What browsers are you seeing the problem on?

No response

Computer operating system

No response

Relevant log output

No response

Validations

michalkleiner commented 6 months ago

Hi @KevinTessier, unfortunately we can't provide support within GitHub issues. We only handle bug reports and feature requests here.

At a quick glance, if you're including the JS tracking snippet as well as MTM snippet in your page head, you will get the tracking twice. If you need to use Matomo Tag Manager, the best bet would be to configure the tracking via MTM and remove the standard JS snippet from your page head.

As this is not a bug in Matomo core, I will close the issue now. For further questions on the topic you may try to post on our forums at https://forum.matomo.org/ or if you're a Matomo Cloud customer you may reach out to our support.

Thanks for your understanding.

KevinTessier commented 6 months ago

thank you for your reply, have a nice day.