Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...Google Analytics and Tracking DownloadsGoogle Analytics and Tracking Downloads
Previous
 
Next
New Post
1/10/2012 7:58 AM
 

Hi

I need to be able to track downloads through Google Analytics automatically (rather than add code to each link). I have seen javascript to achieve this on other sites, but is it possible to use this on Dotnetnuke - I am running 5.6.3. If anyone has achieved this I would appreciate it if you could post how you did it.

Many Thanks


 
New Post
11/19/2012 10:29 PM
 

Hi Vicky,

 Sorry this is so late, I have just seen your post now. 

I'm using a script that tracks document downloads, mailto links and external site links automatically. You can save it as a js file and the link goes in the script template area of your siteanalytics.config file. That means it applies to all portals in an install.

I'll paste it in here, but not sure what the forum will do with the tags but let's give it a go ! The first bit is the full siteanalytics.config file, and the second bit is the full GA_downloadtracker.js file

Cheers,
Anna

****************config file contents***********************

   <?xml version="1.0" encoding="utf-8" ?>
<AnalyticsEngineConfig>
    <Engines>
        <AnalyticsEngine>
            <EngineType>DotNetNuke.Services.Analytics.GoogleAnalyticsEngine, DotNetNuke</EngineType>
      <ElementId>Head</ElementId>
      <InjectTop>False</InjectTop>
            <ScriptTemplate>
                <![CDATA[
<script type="text/javascript" src="/js/GA_downloadtracker.js"></script>               

                <script type="text/javascript">
                  var _gaq = _gaq || [];
                  _gaq.push(['_setAccount', '[TRACKING_ID]']);
                  _gaq.push(['_trackPageview']);
            
                  (function() {
                    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
                    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
                    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
                  })();
                </script>
            
            ]]>

            </ScriptTemplate>
        </AnalyticsEngine>
    </Engines>
</AnalyticsEngineConfig>


       
****************Download tracker script for separate file***********************

if (typeof jQuery != 'undefined') {
    jQuery(document).ready(function($) {
        var filetypes = /\.(zip|exe|pdf|doc*|xls*|ppt*|mp3)$/i;
        var baseHref = '';
        if (jQuery('base').attr('href') != undefined)
            baseHref = jQuery('base').attr('href');
        jQuery('a').each(function() {
            var href = jQuery(this).attr('href');
            if (href && (href.match(/^https?\:/i)) && (!href.match(document.domain))) {
                jQuery(this).click(function() {
                    var extLink = href.replace(/^https?\:\/\//i, '');
                    _gaq.push(['_trackEvent', 'External', 'Click', extLink]);
                    if (jQuery(this).attr('target') != undefined && jQuery(this).attr('target').toLowerCase() != '_blank') {
                        setTimeout(function() { location.href = href; }, 200);
                        return false;
                    }
                });
            }
            else if (href && href.match(/^mailto\:/i)) {
                jQuery(this).click(function() {
                    var mailLink = href.replace(/^mailto\:/i, '');
                    _gaq.push(['_trackEvent', 'Email', 'Click', mailLink]);
                });
            }
            else if (href && href.match(filetypes)) {
                jQuery(this).click(function() {
                    var extension = String((/[.]/.exec(href)) ? /[^.]+$/.exec(href) : undefined);
            var filePath = String(href);
                    _gaq.push(['_trackEvent', 'Download', 'Click-' + extension, filePath]);
                    if (jQuery(this).attr('target') != undefined && jQuery(this).attr('target').toLowerCase() != '_blank') {
                        setTimeout(function() { location.href = baseHref + href; }, 200);
                        return false;
                    }
                });
            }
        });
    });
}
       

   

 
New Post
11/20/2012 12:41 PM
 
This is very much of interest to me as I am also trying to use Google Analytics to track all marketing efforts and do a Remarketing campaign -- a very cool new feature with AdWords. Howeverever, I can't quite figure out how to insert the new code they want (see below). Also, where exactly would your code be inserted and where do you see the tracking (on GA?)? I apologize in advance for the tech newb questions and really, really appreciate your help.


with the bold text in the example below:

 
New Post
11/20/2012 10:53 PM
 
Hi Meredith,

The first part is the full content for the SiteAnanlytics.config file that you'll find in the root folder of the installation (if you have multiple portals it's worth looking up how the config files work over different portals).

The second part can be pasted into notepad and saved as a .js file, in my case I've called it GA_downloadtracker.js and saved it in the /js/ folder in the root folder of the Dnn installation. And that's it!

You will see new Events in the GA interface (called 'External' 'Email' and 'Download'). Click on these, and look at the Event Label for the detail.

I'm working on an update to the script that will auto track buttons and other page object actions as well.

As for the other, sorry, your examples didn't make it to the post - but the remarketing code could go in a skin, or even in a blank module if you don't have access to the skin. But it would be best practise to split the js and the html - the js can be added to the SiteAnanlytics.config file, and the html to the skin.

You could also ask Bruce very nicely (http://www.ifinity.com.au/Products/Go...) if he plans to add remarketing codes to his free Analytics module (very useful for anyone who doesn't have installation or skin access).
 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...Google Analytics and Tracking DownloadsGoogle Analytics and Tracking Downloads


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out