gtag.js (Global Site Tag) is a JavaScript library from Google that is used to easily integrate and control various Google services on a website - in particular for Google Analytics, Google Ads and other marketing and analysis tools.
With gtag.js, a standardised tracking code is provided that records events, page views and Conversions recorded centrally. Website operators can thus define interactions directly in the code without having to integrate several separate tracking scripts.
Typical functions of gtag.js:
- Recording of page views
- Sending customised Events (e.g. clicks, downloads)
- Setting up Conversion tracking
- Link multiple Google services via a single code snippet
gtag.js is the recommended implementation method for newer Google services and replaces older libraries such as analytics.js or the classic Google Ads conversion tags.
Note: As an alternative to the direct integration of gtag.js, the Google Tag Manager which offers additional flexibility in tag management.