how to Be a successful Eiglish Lear 论文怎么写写

用户评论:深圳How to Track Downloads & Outbound Links in Google Analytics | Digital Analytics & Marketing Blog
Analytics and Search Marketing Tips
How to Track Downloads & Outbound Links in Google Analytics
It has been almost 2 years since we published our wildly popular post, .
Since Google Analytics does not track file downloads, email, telephone or other outbound link clicks automatically, we saw an opportunity to provide this code to the community.
In our original post, we provided some explanations and code examples for tracking file downloads in Google Analytics using event tracking.
We decided to revisit our original post and provide a valuable code update that improves performance, makes tracking downloads more manageable and easier to extend.
Dynamically Track Downloads & Other External Links
For those who have a lot of links and would like to dynamically detect clicks on links to file downloads, we have provided updated code below.
As before, this code requires the
to be set before the code.
We have updated the code to make it more manageable and easier to extend.
In addition, we are using the jQuery on() method for attaching the click event handler to links.
Since we are using the on() method you will need to use jQuery v1.7+.
If you are using an earlier version of jQuery the .live() method can be used instead.
The primary benefit of using the on() method is performance.
Instead of looping through all ‘a’ elements on a page after the page loads (takes processing power on pages with lots of links), we instead listen for any clicks on the ‘a’ elements and invoke our custom JavaScript on the fly.
Again, feel free to customize this code to suite your needs.
It can be placed in its own .js file and should be placed in the &head& of your pages.
This script automates the following:
Tracks file downloads as events for the following extensions: .zip, .exe, dmg, .pdf, .doc, .docx, .xls, .xlsx, .ppt, .pptx, .mp3, .txt, rar, wma, mov, avi, wmv, flv, wav (again feel free to modify the list)
Tracks outbound clicks as events if the href value contains http:// or https:// and the domain value doesn’t match the current domain
Tracks mailto email clicks
Tracks Tel telephone clicks
&script type=&text/javascript&&
if (typeof jQuery != 'undefined') {
jQuery(document).ready(function($) {
var filetypes = /\.(zip|exe|dmg|pdf|doc.*|xls.*|ppt.*|mp3|txt|rar|wma|mov|avi|wmv|flv|wav)$/i;
var baseHref = '';
if (jQuery('base').attr('href') != undefined) baseHref = jQuery('base').attr('href');
jQuery('a').on('click', function(event) {
var el = jQuery(this);
var track =
var href = (typeof(el.attr('href')) != 'undefined' ) ? el.attr('href') :&&;
var isThisDomain = href.match(document.domain.split('.').reverse()[1] + '.' + document.domain.split('.').reverse()[0]);
if (!href.match(/^javascript:/i)) {
var elEv = []; elEv.value=0, elEv.non_i=
if (href.match(/^mailto\:/i)) {
elEv.category = &email&;
elEv.action = &click&;
elEv.label = href.replace(/^mailto\:/i, '');
elEv.loc =
else if (href.match(filetypes)) {
var extension = (/[.]/.exec(href)) ? /[^.]+$/.exec(href) :
elEv.category = &download&;
elEv.action = &click-& + extension[0];
elEv.label = href.replace(/ /g,&-&);
elEv.loc = baseHref +
else if (href.match(/^https?\:/i) && !isThisDomain) {
elEv.category = &external&;
elEv.action = &click&;
elEv.label = href.replace(/^https?\:\/\//i, '');
elEv.non_i =
elEv.loc =
else if (href.match(/^tel\:/i)) {
elEv.category = &telephone&;
elEv.action = &click&;
elEv.label = href.replace(/^tel\:/i, '');
elEv.loc =
else track =
if (track) {
_gaq.push(['_trackEvent', elEv.category.toLowerCase(), elEv.action.toLowerCase(), elEv.label.toLowerCase(), elEv.value, elEv.non_i]);
if ( el.attr('target') == undefined || el.attr('target').toLowerCase() != '_blank') {
setTimeout(function() { location.href = elEv. }, 400);
The script sets download, email and tel link clicks as interaction events while the external site clicks are non-interaction which can be adjusted if desired.
As before, the script will detect if the link is opening in a new window or not and automatically uses setTimeout() for 400ms if you are not.
This is to allow time for the hit request to process before taking the user to the new page.
Inline Download & Other External Links Tracking
If you’d rather not use the above method to place a single javascript file on your site and automate the tracking for all link elements, you can use the manual inline approach by tagging each link element individually.
The inline approach can be time consuming and is not scalable.
The original syntax for adding the code inline remains the same.
New window/tab
For links that open a new window or tab (such as using target=”_blank” for example) you will want to use the code below:
&a onclick=&_gaq.push(['_trackEvent','Download','PDF',this.href]);& href=&pdfs/my-file.pdf& target=&_blank&&Download my file&/a&
In current window
For links that open within the same window, replacing the current page, you will want to use the code below:
&a onclick=&var that=_gaq.push(['_trackEvent','Download','PDF',this.href]);setTimeout(function(){location.href=that.},400);& href=&pdfs/my-file.pdf&&Download my file&/a&
These type of links require a slight delay to allow time for the hit request to process before taking the user to the new page.
Detailed Download & External Link Reports
After all of your hard work you will have event tracking reports with neatly organized data around file downloads, external link, email link, and telephone link clicks.
From these reports you can gauge the usage and usefulness of your file downloads and various links.
By diving into the download category and selecting event label as the primary dimension you are able to see a report on all of the individual files downloaded from your site.
Lastly, since events are associated with the page they were fired on, you are able to apply a secondary dimension of page to find out which page contained the download or external link click that occurred.
If you need assistance with outbound link analysis, setup of this tracking code or any other analytics help, don’t hesitate to comment below or contact our .
Related Posts:
Share this Post
Ryan is a Google Analytics Consultant at Blast Analytics & Marketing. With a variety of skills under his belt he spends his days assisting clients with all of their Google Analytics needs. Fueled by music, he relishes a good challenge and is driven to learn.
Add Ryan to your circles on
Ryan Chase has written
on the Web Analytics Blog.
Web Analytics Blog
We're here to help with tips and insight on the following topics:
Optimize your website and marketing campaigns
Get a constant flow of
and online marketing tips, case studies and more from
Blast Analytics & Marketing.
Please fill in your name.
Please enter a valid email address.
Connect with Blast Analytics & Marketing
Recent Posts}

我要回帖

更多关于 个人简历怎么写 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信