Goal-Tracking doesn't work: _paq not defined

I’m trying to track a goal, therefore i use the following code:

echo '<script>_paq.push("trackGoal",2);</script>';

My console says _paq not defined, but when I add the tracking code to my header the console says:

matomo.js:22 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: https://developer.piwik.org/guides/tracking-javascript-guide#multiple-piwik-trackers
ak @ matomo.js:22
matomo.js:22 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: https://developer.piwik.org/guides/tracking-javascript-guide#multiple-piwik-trackers
ak @ matomo.js:22
matomo.js:22 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: https://developer.piwik.org/guides/tracking-javascript-guide#multiple-piwik-trackers

Does anybody know what i might be doing wrong?

Did you setup the goal? Can you acces _paq?

Hi Christina,

this doesn’t look correct to me.
I think the square brackets are missing.

What about if you you try instead this by testing it via your browsers console?

_paq.push(['trackGoal', 2]);

@Trackingninja oh thanks, I forgot the square brackets. It still says _paq is not defined, but tested in my browser console it did work.
I added the matomo tracking code to the page again and now it works but browser console says the same things i added to the original post. but at least the goal is tracked.

That’s good to hear.

But without knowing the way how your code is published / provided on the website it’s still blurry.
For me it sounds like a warning and not an error.

In general multiple trackers should not cause any issues at all.
As long it is properly configured.