Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to access MatamoTagManager variable in matomoTagManagerAsyncInit #400

Closed
FalkHe opened this issue Dec 21, 2021 · 2 comments · Fixed by #401
Closed

Unable to access MatamoTagManager variable in matomoTagManagerAsyncInit #400

FalkHe opened this issue Dec 21, 2021 · 2 comments · Fixed by #401
Labels
Bug Something isn't working

Comments

@FalkHe
Copy link

FalkHe commented Dec 21, 2021

I want to access the dataLayer of MTM. The Documentation says, the following should do the tick:

window.matomoTagManagerAsyncInit = function () {
    MatomoTagManager.THROW_ERRORS = false;
}

Doing the exact same thing, the console yields: "MatomoTagManager is undefined"

however, the following works but shouldn't be the right solution.

window.matomoTagManagerAsyncInit = function () {
  setTimeout(function(){
    MatomoTagManager.THROW_ERRORS = false;
  }, 1)
}

IMO this line:

if ('matomoTagManagerAsyncInit' in windowAlias && utils.isFunction(windowAlias.matomoTagManagerAsyncInit)) {

should be at the very bottom.

@FalkHe
Copy link
Author

FalkHe commented Dec 21, 2021

I created a (my first) Pull Request

@tsteur tsteur added the Bug Something isn't working label Dec 21, 2021
@tsteur tsteur added this to the Current sprint milestone Dec 21, 2021
@AltamashShaikh AltamashShaikh changed the title matomoTagManagerAsyncInit is called in the wrong place Unable to access MatamoTagManager variable in matomoTagManagerAsyncInit Jan 11, 2022
@FalkHe
Copy link
Author

FalkHe commented Jan 11, 2022

Thanks for the accepted PR :)

The Documentation should be Updated, too.

Instead of

window.matomoTagManagerAsyncInit = function () {
    MatomoTagManager.THROW_ERRORS = false;
}

it should now be

window.matomoTagManagerAsyncInit = function (tagManagerInstance) {
    tagManagerInstance.THROW_ERRORS = false;
}

I created a PR on this, too. :)

@innocraft-automation innocraft-automation removed this from the Current sprint milestone Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants