Google Analytics to track downloads - General Discussions - General Discussions - Progress Community
 General Discussions

Google Analytics to track downloads

  • Google Analytics to track downloads
  • Hello,

    I need to have google analytics track document download stats.  In the past I believe I found a forum post that provided instructions for getting version 3.x to do so however I'm now going to be running version 4 so I'm looking on some guidance on how I'd go about enabling this.  I know that I can tag links individually but its the document library that is my main concern.

  • Hello Jason,

    It is possible to include the necessary code for the Google Analytics tracking by editing the template of your document list widget. To do that create a Sitefinity web page and drop the Download list widget somewhere on the page. After that click on the Edit-> Settings->Edit Thumbnail List Templates and choose the template you are currently using. For example if you are using the List you have to edit the Documents - list template. In the ItemTemplate you can simply add the link reference with the necessary code to track Google Analytics.

    Here is the edited template that I created in order to implement your scenario:

    <%@ Control Language="C#" %>
    <%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.PublicControls.BrowseAndEdit" Assembly="Telerik.Sitefinity" %>
    <%@ Register TagPrefix="sitefinity" Namespace="Telerik.Sitefinity.Web.UI" Assembly="Telerik.Sitefinity" %>
    <sf:BrowseAndEditToolbar ID="browseAndEditToolbar" runat="server" Mode="Edit"></sf:BrowseAndEditToolbar>
    <div id="itemsContainer" runat="server">
        <asp:Repeater ID="documentsRepeater" runat="server">
                <ul class="sfdownloadList sfListMode">
                <li id="docItem" runat="server" class="sfdownloadFile">
    <a href="<%# Eval("MediaUrl")%>"  runat="server"  title="Download" target="_blank" onClick="javascript: _gaq.push(['_trackPageview', '/downloads/<%# Eval("Title")%>']);"><%# Eval("Title")%></a>
                    <sitefinity:SitefinityLabel id="infoLabel" runat="server" WrapperTagName="div" HideIfNoText="false" CssClass="sfInfo" />
    <sitefinity:Pager id="pager" runat="server"></sitefinity:Pager>

    I have manually included the link tag with the necessary code from google that is explained in their How do I track files document.

    Note that in order to properly execute the code you will also need the Google Tracking code that will insert the needed to properly execute the onClick function above.

    Please let me know whether you have any further questions.

    Kind regards,
    Hristo Borisov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  • Could you point me in the right direction for implementing this on 3.x? I searched, but could not find the post you mentioned. I understand how this works in GA, just don't know how to implement without doing it manually for each link.

    Thank you!
  • Hi Brooke,

    I've written such post some time ago, please check it here -

    All the best,
    the Telerik team