The command is ignored. Unknown target: undefined when setting the Custom Size setting in the Google Analytics tracking code

I’m setting a custom dimension in my Google Analytics tracking code, however I see a strange error in the Chrome console with the Google Analytics debugger turned on.

This is my code that runs on every page. I report the regional account, as well as the global account with the drive, and for this I created two trackers.

<script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
                (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
            m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

    ga('create', 'UA-85521872-1', 'auto', 'crmpiccoglobal');
    ga('create', 'UA-85521872-3', 'auto', 'crmpiccoregion');

    ga('set', 'dimension1', 'premium');

    ga('crmpiccoglobal.send', 'pageview');
    ga('crmpiccoregion.send', 'pageview');
</script>

In the console, I see the following:

Run command: ga ("set", "dimension1", "premium")

analytics_debug.js: 10 The command is ignored. Unknown target: undefined

I created a custom dimension in GA for each property that I want to access.

+6
3

"set", GA t0 ( ):

  ga('crmpiccoglobal.set', 'dimension1', 'premium');
  ga('crmpiccoregion.set', 'dimension1', 'premium');

  ga('crmpiccoglobal.send', 'pageview');
  ga('crmpiccoregion.send', 'pageview');
+12

Google Tag Manager Google Analytics , , :

sendGa(name : string, data: any) {
    (<any>window).ga(() => {
        var trackers = (<any>window).ga.getAll();
        var firstTracker = trackers[0];
        var trackerName = firstTracker.a.data.values[":name"];
        (<any>window).ga(trackerName + '.' + name, data);
    });
}

: https://developers.google.com/analytics/devguides/collection/analyticsjs/accessing-trackers

+1

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


All Articles