Google Tag Manager (legacy)

This is the client-side Google Tag Manager Template for Amplitude Analytics. The tag uses the Maintenance Amplitude JavaScript SDK for data collection.

This is a legacy template

This is a legacy GTM template. Use the latest template for the most up-to-date implementation.

Migration

The Amplitude Analytics Legacy template, currently utilizing the Maintenance Amplitude JavaScript SDK for data collection, is only slated for bug fixes until its eventual deprecation. use the latest GTM template that uses Amplitude's Marketing Analytics SDK for data collection. This not only ensures better support but also offers access to a host of new features.

  • The latest template isn't backwards compatible with this legacy template due to the non-backwards compatibility of the internal SDK. It does a cookie migration logic to help the transition of legacy cookies information to the latest cookie storage system.
  • For a comprehensive migration guide, see the Migration guide.
  • To understand the behavioral differences between the old and new templates, see the comparison section.

Here are the breaking changes:

Change Area
Amplitude Analytics Browser SDK (GTM Client Template Latest) Amplitude Analytics Legacy (GTM Client Template Maintenance)
Core SDK Marketing Analytics Browser SDK. Maintenance Amplitude JavaScript SDK.
Amplitude initialization The init function is a separate tag type that requires a dedicated tag. This accommodates deferred initialization, which allows the init tag to be called even after an event track call. However, it's critical to note that events won't be dispatched to Amplitude until the init tag is explicitly activated. The init is called by default. As there's no separate init tag, the initialization process runs as soon as the template is loaded.
Web Attribution Collects more click IDs and is much easier to configure. Simply enable attribution tracking in the init type tag for default behavior. Further details are available. Set the initialization Options for each tag type is required unless you are using default configuration. Refer to this comparison for the differences in web attribution behavior between the core SDKs. For configuration mapping between the core SDKs, see the Migration guide.
Page View Tracking Includes built-in Page View Tracking which can be configured in the init type tag. You can set up the page view tracking trigger and decide whether to track history events automatically. No built-in Page View Tracking. You can implement your page view tracking using the track type tag. For Single Page Applications (SPAs), the All Pages trigger isn't sufficient for tracking history changes. All Pages and History Changes triggers should be added as trigger for the page view tracking accuracy. If you wish to add some automatic variables provided by the History Change trigger, navigate to the variable section, configure, and activate all checkboxes under History. Once enabled, you'll see these history variables in the Variables tab in the GTM preview pane.

EU data residency

For EU data residency, you must set up your project inside Amplitude EU and use the API key from Amplitude EU. You can configure the server zone by checking the checkbox EU Data Residency under Tag Configuration -> Initialization.

Was this page helpful?

Thanks for your feedback!

June 28th, 2024

Need help? Contact Support

Visit Amplitude.com

Have a look at the Amplitude Blog

Learn more at Amplitude Academy

© 2024 Amplitude, Inc. All rights reserved. Amplitude is a registered trademark of Amplitude, Inc.