HxGoogleTagManager #

Adds Google Tag Manager to the application and manages communication with GTM JavaScript (data-layer).

Basic usage #

Install GTM support through application startup:

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

API #

Methods #

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.

HxGoogleTagManagerPageViewTracker #

Basic usage #

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

<HxGoogleTagManagerPageViewTracker />

API #

An unhandled error has occurred. Reload 🗙