DNN Google Tag Manager 02.03.00 released

We’re happy to announce the availability of DNN Google Tag Manager 02.03.00. This release adds support for Google Tag Manager’s Data Layer.

This version adds a new (portal specific) option “Enable data layer”, that (if checked) injects the Google Tag Manager’s Data Layer JavaScript object into the page (see https://developers.google.com/tag-manager/devguide). Without any additional coding, an empty data layer object is injected:

dataLayer = [];

To add custom data to the data layer object, you can add a class that implements weweave.DnnGoogleTagManager.Extension.IDataLayerProvider to your backend code. A sample implementation looks like this:

public class SampleDataLayerProvider : weweave.DnnGoogleTagManager.Extension.IDataLayerProvider
{
  /// <summary>
  /// Updates the data layer
  /// </summary>
  /// <param name="request">Request to update the data layer
  /// <param name="user">User to update the data layer (or null for anonymous requests)
  /// <param name="dataLayer">Data layer to update
  /// <returns>Updated data layer</returns>
  public Dictionary<string, string=""> UpdateDataLayer(HttpRequestBase request, UserInfo user, Dictionary<string, string=""> dataLayer)
  {
    dataLayer["key1"] = "value1";
    dataLayer["key2"] = "value2";
    // ...
    return dataLayer;
  }

  /// <summary>
  /// Priority of this IDataLayerProvider implementation; implementation with higher lower priority can override the
  /// data layer of implementation with lower priority
  /// </summary>
  /// <param name="request">Request to get the priority for
  /// <param name="user">User to get the priority for (or null for anonymous requests)
  /// <returns>Priority of this IDataLayerProvider implementation</returns>
  public int GetPriority(HttpRequestBase request, UserInfo user)
  {
    return 1;
  }
}</string,></string,>

The module automatically creates new instances of all defined IDataLayerProvider and calls UpdateDataLayer(…) in the order of the providers’ priorities to get all data for the data layer.

More information: