Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track button, markdown help and external link clicks #3723

Merged
merged 3 commits into from
Jan 29, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ gem 'friendly_id', '~> 5.2.1'
gem 'gds-sso', '~> 13.5'
gem 'globalize', '5.1.0'
gem 'govuk_ab_testing', '~> 2.4x'
gem 'govuk_admin_template', '~> 6.2'
gem 'govuk_admin_template', '~> 6.5'
gem 'govuk_app_config', '~> 1.2.0'
gem 'govuk_sidekiq', '2.0.0'
gem 'invalid_utf8_rejector', '~> 0.0.4'
Expand Down
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ GEM
rails (>= 4.2)
sass (> 3.4)
ast (2.3.0)
autoprefixer-rails (7.2.1)
autoprefixer-rails (7.2.5)
execjs
babosa (1.0.2)
better_errors (2.4.0)
Expand Down Expand Up @@ -189,7 +189,7 @@ GEM
rubocop-rspec (~> 1.19.0)
scss_lint
govuk_ab_testing (2.4.1)
govuk_admin_template (6.2.0)
govuk_admin_template (6.5.0)
bootstrap-sass (= 3.3.5.1)
jquery-rails (~> 4.3.1)
rails (>= 3.2.0)
Expand Down Expand Up @@ -560,7 +560,7 @@ DEPENDENCIES
govuk-content-schema-test-helpers
govuk-lint (~> 3.6.0)
govuk_ab_testing (~> 2.4x)
govuk_admin_template (~> 6.2)
govuk_admin_template (~> 6.5)
govuk_app_config (~> 1.2.0)
govuk_frontend_toolkit (= 7.2.0)
govuk_sidekiq (= 2.0.0)
Expand Down
18 changes: 18 additions & 0 deletions app/assets/javascripts/admin/modules/track_button_click.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
(function(Modules) {
"use strict";

Modules.TrackButtonClick = function() {
this.start = function(container) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is our convention to use $ for elements e.g. $container?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It hasn't been a convention in the admin scripts. No reason it shouldn't be.

var trackClick = function() {
var category = container.data("track-category"),
action = container.data("track-action") || "button-pressed",
label = $(this).is(":input") ? $(this).val() : $(this).text();

GOVUKAdmin.trackEvent(category, action, { label: label });
};

container.on("click", ".btn", trackClick);
}
};

})(window.GOVUKAdmin.Modules);
2 changes: 1 addition & 1 deletion app/views/admin/editions/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<% page_class "edition-show" %>
<% initialise_script "GOVUK.adminEditionShow" %>

<div class="row">
<div class="row" data-module="track-button-click" data-track-category="button-pressed" data-track-action="<%= @edition.format_name.parameterize(separator: '-') %>-button">
<div class="<%= @edition.imported? ? "col-md-6" : "col-md-8" %> edition-metadata">
<%= render partial: 'show_metadata' %>
</div>
Expand Down
2 changes: 1 addition & 1 deletion lib/whitehall/form_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def error_list
end

def form_actions(options = {})
@template.content_tag(:div, "class" => "form-actions") {
@template.content_tag(:div, "class" => "form-actions", data: { module: 'track-button-click', 'track-category' => 'form-button', 'track-action' => "#{object.class.name.demodulize.underscore.dasherize}-button" }) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be easier to read if this was on more than one line (but I don't know if there's a way of doing that).

options[:buttons].each do |name, value|
@template.concat submit(value, name: name, class: "btn btn-primary btn-lg")
end
Expand Down