quotation from https://developers.google.com/gtagjs/reference/api

gtag(<command>, <command parameters>);

<command> is one of three gtag commands: config, set, or event.

but snippet provided by https://developers.google.com/analytics/devguides/collection/gtagjs/ contains such line

gtag('js', new Date());

What's her job?

  • I'm not sure. My guess is that the date is used as a cache busting parameter. See What is cache busting? · Curtis Timson which has a section about using dates and times. I'm not sure why you would have to pass the date into that function though. I'd think it could just instantiate a new date on its own if it needed one for cache busting. – Stephen Ostermiller Jan 7 at 10:08
  • @StephenOstermiller, Or could it have something to do with [support.google.com/analytics/answer/6086069?hl=en] ? – nichijou Jan 7 at 14:01
  • Could be. Again, I don't know why you would have to pass the date in for that either. – Stephen Ostermiller Jan 7 at 14:29
  • @StephenOstermiller, maybe serve as some kind of self-explanatory stuff – nichijou Jan 7 at 23:27

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.