Google Tag Manager, requirejs and CLI Aurelia

I have an Aurelia CLI application in which I am trying to include de Google Tag Manager

<head>
    <!-- Google Tag Manager -->
    <!--<script>
        var dataLayer = [];
        dataLayer.push({ 'event': 'hixo' });
    </script>
    <script>
        (function (w, d, s, l, i) {
            w[l] = w[l] || []; w[l].push({
                'gtm.start':
                    new Date().getTime(), event: 'gtm.js'
            }); var f = d.getElementsByTagName(s)[0],
                    j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : ''; j.async = true; j.src =
            'https://www.googletagmanager.com/gtm.js?id=' + i + dl; f.parentNode.insertBefore(j, f);
        })(window, document, 'script', 'dataLayer', 'GTM-PLSZRC');
    </script>-->
    <!-- End Google Tag Manager -->
</head>

But as soon as I run the application, I get the following error requirejs:

"Mismatched anonymous define() modules"

In the CLI, Aurelia is used requirejs, but it is completely abstracted, so where and how should I define the Google Script Tag Manager so that it is not treated as an anonymous module?

+4
source share
1 answer

dataLayer.push() google script, GTM . , aurelia-cli ( requirejs, ). RequireJS , GTM script aurelia-cli.

, Google, - Fingerprint2 URL. 1.4.1 Fingerprint2, GitHub , Mismatched anonymous define(). , PR, Google Fingerprint2 ( ), .

, Fingerprint2 script, RequireJS Mismatched anonymous define(), Google, Fingerprint2 :

<script src="http://www.clickcease.com/monitor/stat.js"></script>
<script src="scripts/vendor-bundle.js" data-main="aurelia-bootstrapper"></script>
<script>
  requirejs.onError = function (err) {
    if (err.message.indexOf('Fingerprint2') === -1) {
      throw err;
    }
  };
</script>

, Clickcease Fingerprint2, .

+2

Source: https://habr.com/ru/post/1667561/


All Articles