Support for Google Tag Manager - initialization and pushing data to data-layer.

Basic usage

Install GTM support through application statup:

builder.Services.AddHxGoogleTagManager(options =>
	builder.Configuration.Bind("HxGoogleTagManager", options);



Method Returns Description
InitializeAsync() Task Initializes the GTM support. Called automatically within first Push call (incl. HxGoogleTagManagerPageViewTracker calls). To be used explicitly only in those rare cases when you want to initialize GTM without pushing any data.
PushAsync(object data) Task Push generic data to GTM data-layer (using regular JSON-serialization).
PushEventAsync(string eventName, object eventData) Task Push event to GTM data-layer.
PushPageViewAsync(object additionalData) Task Push page-view to GTM data-layer. Consider using HxGoogleTagManagerPageViewTracker instead of manual handling.


Basic usage

Install GTM support through application statup (see above) and add HxGoogleTagManagerPageViewTracker to App.razor or MainLayout.razor

<HxGoogleTagManagerPageViewTracker />


An unhandled error has occurred. Reload 🗙