Universal Analytics (UA) will be deprecated on July 1, 2023, which means it will stop processing data. Analytics 360 properties will stop working on October 1, 2023. Migrate to Google Analytics 4.

Rename the gtag object

Stay organized with collections Save and categorize content based on your preferences.

In some cases you'd like to add gtag.js to your page, but gtag() is already being used for something else. gtag.js allows you rename the global gtag() object to avoid name conflicts.

Rename the global object

To rename the global object, change gtag() in the global site tag to another name. For any instances where gtag() is called in your code, be sure to rename them to match.

For example, to rename the gtag() object to analytics(), change the tag as follows:

<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=TRACKING_ID"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function analytics(){dataLayer.push(arguments);}
  analytics('js', new Date());

  analytics('config', 'TRACKING_ID');
</script>