What is the appropriate syntax of google analytics.create method

according to the ga method reference , the syntax of the .create method:

ga('create', trackingId, opt_configObject); 

But when I create a new ga account and it gives me an autogenerated piece of code to copy / paste to my site, it gives me a different .create syntax:

 ga('create', trackingId, 'mydomain.com'); 

I don't see anything in the method reference, which suggests that the second syntax is acceptable.

The ga forum also has an unanswered thread: ga-forum thread .

+4
source share
1 answer
 ga('create', 'UA-foobar', 'mydomain.com'); 

is IMO equivalent

 ga('create', 'UA-foobar', { 'cookieDomain': 'mydomain.com' }); 

Some information:

I graced http://www.google-analytics.com/analytics.js via jsbeautifier.org and created this jsfiddle http://jsfiddle.net/4MRwj/2/ On line 1044 you will find a method for creating Google Analytics. I just edited 3 LOC in this file. On line 1047, I added some debugging information using alert (), and on lines 1060 and 1061 I manually call the create method using different arguments. Both calls result in the same debugging information as when you started it.

+2
source

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


All Articles