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?

  • 1
    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. Jan 7, 2019 at 10:08
  • @StephenOstermiller, Or could it have something to do with [support.google.com/analytics/answer/6086069?hl=en] ?
    – nichijou
    Jan 7, 2019 at 14:01
  • Could be. Again, I don't know why you would have to pass the date in for that either. Jan 7, 2019 at 14:29
  • @StephenOstermiller, maybe serve as some kind of self-explanatory stuff
    – nichijou
    Jan 7, 2019 at 23:27

2 Answers 2


It's for setting GA's cookie and reporting timezone/region/language to various functions responsible for functionality based on time...which is a lot. Most things in Google Analytics revolve around time in one way or another. For example session durations, time on page, the time of day that users visit your site, etc.


Couldn't find more information out there but I think it could be like similar to gtm.start but for gtag. See more about gtm.start here: https://hume.dev/articles/gtm-start/ It might either be useful for tracking loading time (performance) or for serving as a seed for calculating unique ids per page load.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.