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

JavaScript tracker: change Piwik.addTracker() to allow not setting an idSite #14781

Closed
mattab opened this issue Aug 17, 2019 · 0 comments · Fixed by #14787
Closed

JavaScript tracker: change Piwik.addTracker() to allow not setting an idSite #14781

mattab opened this issue Aug 17, 2019 · 0 comments · Fixed by #14787
Assignees
Labels
Bug For errors / faults / flaws / inconsistencies etc. Regression Indicates a feature used to work in a certain way but it no longer does even though it should.
Milestone

Comments

@mattab
Copy link
Member

mattab commented Aug 17, 2019

Could we change Piwik.addTracker() to allow not setting an idSite there, and only have the first parameter URL instead?

This is needed to fix a big regression in Tag Manager.

Why needed now?

This started being an issue a few weeks since we changed: matomo-org/tag-manager@f0e368d as we are no longer setting the idsite.

Reproduce

Steps sent by a customer (haven't reproduced it myself, but can see the error live on their site):

  • Use tag manager and Matomo separately for example:
 <!-- Matomo -->
    <script type="text/javascript">
        var _paq = window._paq || [];
        /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
        _paq.push(['trackPageView']);
        _paq.push(['enableLinkTracking']);
        (function() {
            var u="https://URL_HERE/";
            _paq.push(['setTrackerUrl', u+'matomo.php']);
            _paq.push(['setSiteId', '1']);
            var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
            g.type='text/javascript'; g.async=true; g.defer=true; g.src='URL_HERE/matomo.js'; s.parentNode.insertBefore(g,s);
        })();
    <!-- End Matomo Code -->

​    <!-- Matomo Tag Manager -->
        window._mtm = window._mtm || [];
        window._mtm.push({'mtm.startTime': (new Date().getTime()), 'event': 'mtm.Start'});
        var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
        g.type='text/javascript'; g.async=true; g.defer=true; g.src='https://URL_HERE/js/container_uAZDfecL.js'; s.parentNode.insertBefore(g,s);
    </script>
    <!-- End Matomo Tag Manager -->

  • Create a container
  • Create custom html Tag with the following code:
        try {
            window._mtm = window._mtm || [];
            window._mtm.push(data);
            console.log('mtm', data);
        }
        catch (e) {
            console.log('matomo error', e);
        }

(data could be eg. { category: "clic-réseaux-sociaux", event: "clic-réseaux-sociaux", label: "nom-réseaux-facebook" }

JS Error when using tag manager:

matomo error Error: A siteId must be given to add a new tracker
at Q.addTracker (matomo.js:63)
at Object.addTracker (matomo.js:74)
at container_uAZDfecL.js:357
at Object.push (container_uAZDfecL.js:43)
at Object.fire (container_uAZDfecL.js:356)
at g._doFire (container_uAZDfecL.js:36)
at g.fire (container_uAZDfecL.js:36)
at container_uAZDfecL.js:33
at Array.<anonymous> (container_uAZDfecL.js:384)
at t.push (container_uAZDfecL.js:21)
@mattab mattab added Bug For errors / faults / flaws / inconsistencies etc. Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical. Regression Indicates a feature used to work in a certain way but it no longer does even though it should. labels Aug 17, 2019
@mattab mattab added this to the 3.12.0 milestone Aug 17, 2019
@tsteur tsteur self-assigned this Aug 18, 2019
@mattab mattab removed the Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical. label Oct 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. Regression Indicates a feature used to work in a certain way but it no longer does even though it should.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants