Piwik.js loaded twice -- The method enableLinkTracking is registered more than once in "_paq" variable

Hello,

I just installed Piwik on my server and is working OK, already tracking visits.

However, when I look on the console I see these three errors:

The method enableLinkTracking is registered more than once in “_paq” variable. Only the last call has an effect. Please have a look at the multiple Piwik trackers documentation: JavaScript Tracking Client: API Reference - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v3 piwik.js:50

The method setTrackerUrl is registered more than once in “_paq” variable. Only the last call has an effect. Please have a look at the multiple Piwik trackers documentation: JavaScript Tracking Client: API Reference - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v3 piwik.js:50

The method setSiteId is registered more than once in “_paq” variable. Only the last call has an effect. Please have a look at the multiple Piwik trackers documentation: JavaScript Tracking Client: API Reference - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v3

I’ve been looking for a solution for it, but haven’t found anything, any ideas why those errors happen? I just copied the tracking code that contains the siteid and all this information.

I also double-checked that the tracking code is called once (just in case).

Thank you.

Sergi.

I also realised that piwik.js is added twice in my section, so that’s probably what is causing it, still haven’t found a solution. Any ideas for it?

I know this is a month old now and maybe the OP was able to solve his issue.
But I had this problem today out of nowhere, too and Google results lead among others to this thread when searching for the exact same error msgs mentioned above with a double insertion of the piwik JS.

I had the production version as comparison to the dev version and was able to figure it out after some hours thinking it is a Piwik specific problem. But it isn’t. At last not necessarily.
I had a portion of my local code commented out, unfortunately I left a not closed HTML div element in the middle of my website leading to this specific problem. Odd as it sounds.
Not sure about the exact context it leads to this issue as a

dircetly before the tracking code doesn’t do anything.

The basic structure of my site looked like this and the underlined div before the comment lead to the issue.


<body>
<div>
    <div>
	<ol>
            <li></li>
	</ol>
    </div>
    <div>
        <h1></h1>
        [u]<div>[/u]
		<!-- some code pieces commented out with HTML comment <?php /* Some PHP code commented out so that it isn't visible in the website source either */ ?> -->
        <div>
		<h2></h2>
                <span></span>
        </div>
    </div>
</div>
...
<!-- Piwik tracking code below -->
...
</body>

Removing the div and the issue is gone, putting it back in, issue reappears with said error messages. It wouldn’t happen with a, span, h1 or alike, only with div, though.
So a possible solution for this issue is checking your HTML for validity. Mainly check your div or perhaps other block elements.
The reasoning for this might be more complex than I described but it may solve similar issues notheless.

That makes sense. I installed the tracking code on a different website and it’s not throwing those errors.

I have changed some things but still haven’t found the issue, but your comment was really helpful.

I’ll post whatever I find out.

Thank you for your help!

Sergi.

Well, finally found out that my Javascript was replacing some characters on the body page and that was causing the page to reload the whole body, that is with the Piwik code in it.

My bad!

I had also faced this issue… Then i find-out why this is happening.
I deploy the matomo on e-commerce store so i have deploy tracking code and
e-commerce plugin both…
So when i remove tracking code from store the error is resolve because both are tracking code… So if you are using any plugin then don’t use tracking code