Skip to content

Commit

Permalink
Merge pull request #631 from alphagov/link-tracking
Browse files Browse the repository at this point in the history
Add download and external link tracking
  • Loading branch information
edds committed Aug 6, 2015
2 parents b9a326f + 1b01df3 commit 77c23f5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ group :development, :test do
end

gem 'plek', '1.11.0'

gem 'govuk_frontend_toolkit', '~> 4.1.1'
gem 'govuk_frontend_toolkit', '~> 4.2.0'

if ENV['GOVUK_TEMPLATE_DEV']
gem 'govuk_template', :path => "../govuk_template"
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ GEM
plek
rack-cache
rest-client (~> 1.8.0)
govuk_frontend_toolkit (4.1.1)
govuk_frontend_toolkit (4.2.0)
rails (>= 3.1.0)
sass (>= 3.2.0)
govuk_template (0.13.0)
Expand Down Expand Up @@ -186,7 +186,7 @@ DEPENDENCIES
capybara (= 2.1.0)
exception_notification
gds-api-adapters (= 20.1.1)
govuk_frontend_toolkit (~> 4.1.1)
govuk_frontend_toolkit (~> 4.2.0)
govuk_template (= 0.13.0)
image_optim (= 0.17.1)
jasmine-rails (~> 0.10.6)
Expand Down
2 changes: 2 additions & 0 deletions app/assets/javascripts/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//= require govuk/analytics/analytics
//= require govuk/analytics/print-intent
//= require govuk/analytics/error-tracking
//= require govuk/analytics/external-link-tracker
//= require govuk/analytics/download-link-tracker

//= require analytics/static-analytics
//= require analytics/init
Expand Down
8 changes: 6 additions & 2 deletions app/assets/javascripts/analytics/static-analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
// Begin error and print tracking
GOVUK.analyticsPlugins.error();
GOVUK.analyticsPlugins.printIntent();
GOVUK.analyticsPlugins.externalLinkTracker();
GOVUK.analyticsPlugins.downloadLinkTracker({
selector: 'a[href*="/government/uploads"], a[href*="assets.digital.cabinet-office.gov.uk"]'
});

function setPixelDensityDimension() {
if (window.devicePixelRatio) {
Expand Down Expand Up @@ -91,8 +95,8 @@
this.setRenderingApplicationDimension(dimensions['rendering-application']);
};

StaticAnalytics.prototype.trackPageview = function(path, title) {
this.analytics.trackPageview(path, title);
StaticAnalytics.prototype.trackPageview = function(path, title, options) {
this.analytics.trackPageview(path, title, options);
};

StaticAnalytics.prototype.trackEvent = function(category, action, options) {
Expand Down

0 comments on commit 77c23f5

Please sign in to comment.