More in this section

Forums / General Discussions / Google Analytics to track downloads

Google Analytics to track downloads

4 posts, 0 answered
  1. Jason
    Jason avatar
    16 posts
    Registered:
    27 Aug 2008
    20 Jan 2011
    Link to this post
    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.

    Thanks,
    Jason
  2. Hristo Borisov
    Hristo Borisov avatar
    190 posts
    Registered:
    19 Jun 2017
    25 Jan 2011
    Link to this post
    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">
            <HeaderTemplate>
                <ul class="sfdownloadList sfListMode">
            </HeaderTemplate>
            <ItemTemplate>
                <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" />
                </li>
            </ItemTemplate>
            <FooterTemplate>
                </ul>
            </FooterTemplate>
        </asp:Repeater>
    </div>
    <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 http://www.google-analytics.com/ga.js 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
  3. Brooke
    Brooke avatar
    1 posts
    Registered:
    07 Dec 2010
    16 Feb 2011
    Link to this post
    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!
  4. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
4 posts, 0 answered