Implementing Google Analytics’ User ID feature with DNN Google Analytics Advanced

Update: DNN Google Analytics Advanced 03.01.00 offers a checkbox to easily switch the User ID feature on and off and no longer require the steps below.

One of the great benefits of Google Universal about Google Analytics Classic is the User ID feature (see here for more information). In a nutshell, this feature allows you to track your users across different devices (such as phone, tablet or desktop). Technically, you provide the user’s id to Google Analytics (after the user has logged in) so that Google Analytics is able to recognize the user even after he has switched the device. Since DNN does not offer support for Google Analytics Universal out-of-the-box, DNN Google Analytics Advanced is a great help in setting up this feature.

In the following you find a detailed step by step instruction how to set up the User ID feature with DNN Google Analytics Advanced 02.03.00 or newer. Please note that the necessary changes to the Default.aspx file are not “upgrade-safe”. In other words: You have to reapply those after upgrading DNN.

  1. Install and set up DNN Google Analytics Advanced by following the installation instructions.
  2. Set up the User ID feature by following this instructions.
  3. Change the Default.aspx file in your website’s root folder and add
    <asp:placeholder runat="server">
      <script>window.dnnUserId = '<%=UserController.GetCurrentUserInfo().UserID%>';</script>

    just before

    <asp:PlaceHolder runat="server" ID="ClientDependencyHeadCss"></asp:PlaceHolder>
  4. Change the DNN Google Analytics Advanced settings as follows:
    • Enable “Advanced mode”.
    • Set “Google Analytics script type” to “Universal”.
    • Set “Before pageview callback” to:
      if (window.dnnUserId >= 0) ga('set', 'userId', window.dnnUserId);

At the moment, we are working on a new version of DNN Google Analytics Advanced that will add support for the User ID feature in a way that it is “upgrade-safe” and can be enabled even simpler by checking a checkbox.

More information: