govuk_admin_template 1.5.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +1 -0
- data/app/assets/javascripts/govuk-admin-template/govuk-admin.js +20 -17
- data/app/assets/javascripts/govuk-admin-template/modules/auto_track_event.js +1 -1
- data/app/views/layouts/govuk_admin_template.html.erb +11 -0
- data/lib/govuk_admin_template/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1be05142b9ea4a7b5df0e994e877937293135fdf
|
|
4
|
+
data.tar.gz: ad1fcdff74b55e486565929230502b92898e7f89
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1edc24beaaa1ef1fdf833072659ecff6333f57a7d8f85e45457005041a0459d468505058756601be8d71219387a2957285aab34e339b6b67a8420d9222a722c0
|
|
7
|
+
data.tar.gz: 94d8caafc79f568d1eaea021f559ea87165144af352d6d4654f39e23bd998352d1aee561b37f1dbf36f9a73bb76c9eba58e443e305ae7d7c35d3821dd994997c
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -10,6 +10,7 @@ This gem provides (via a Rails engine):
|
|
|
10
10
|
* Admin design patterns available from `/style-guide` (when routes are mounted)
|
|
11
11
|
* [CSS helpers and SASS variables](CSS.md) for the admin theme
|
|
12
12
|
* GOV.UK user friendly date formats
|
|
13
|
+
* Google Analytics tracking code (Universal Analytics), using the "GOV.UK apps" profile
|
|
13
14
|
|
|
14
15
|
[Apps using this gem](https://github.com/search?q=govuk_admin_template+user%3Aalphagov+filename%3AGemfile) include:
|
|
15
16
|
* [Transition](https://github.com/alphagov/transition)
|
|
@@ -70,26 +70,34 @@
|
|
|
70
70
|
window.location.href = path;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
// Google Analytics pageview tracking
|
|
74
|
+
GOVUKAdmin.trackPageview = function(path, title) {
|
|
75
|
+
var pageviewObject = { page: path };
|
|
76
|
+
|
|
77
|
+
if (typeof title === "string") {
|
|
78
|
+
pageviewObject.title = title;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (typeof root.ga === "function") {
|
|
82
|
+
// https://developers.google.com/analytics/devguides/collection/analyticsjs/pages
|
|
83
|
+
root.ga('send', 'pageview', pageviewObject);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
73
87
|
// Google Analytics event tracking
|
|
74
88
|
// Label and value are optional
|
|
75
|
-
GOVUKAdmin.
|
|
89
|
+
GOVUKAdmin.trackEvent = function(action, label, value) {
|
|
76
90
|
|
|
91
|
+
// https://developers.google.com/analytics/devguides/collection/analyticsjs/events
|
|
77
92
|
// Default category to the page an event occurs on
|
|
78
|
-
var
|
|
79
|
-
|
|
80
|
-
// https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide
|
|
81
|
-
eventGa = ["_trackEvent", category, action],
|
|
82
|
-
|
|
83
|
-
// https://developers.google.com/analytics/devguides/collection/analyticsjs/events
|
|
84
|
-
eventAnalytics = {
|
|
93
|
+
var eventAnalytics = {
|
|
85
94
|
hitType: 'event',
|
|
86
|
-
eventCategory:
|
|
95
|
+
eventCategory: root.location.pathname,
|
|
87
96
|
eventAction: action
|
|
88
97
|
};
|
|
89
98
|
|
|
90
99
|
// Label is optional
|
|
91
100
|
if (typeof label === "string") {
|
|
92
|
-
eventGa.push(label);
|
|
93
101
|
eventAnalytics.eventLabel = label;
|
|
94
102
|
}
|
|
95
103
|
|
|
@@ -99,18 +107,13 @@
|
|
|
99
107
|
if (value) {
|
|
100
108
|
value = parseInt(value, 10);
|
|
101
109
|
if (typeof value === "number" && !isNaN(value)) {
|
|
102
|
-
eventGa.push(value);
|
|
103
110
|
eventAnalytics.eventValue = value;
|
|
104
111
|
}
|
|
105
112
|
}
|
|
106
113
|
|
|
107
|
-
// _gaq is the Google Analytics tracking object we
|
|
108
|
-
// push events to when using the old tracking code
|
|
109
|
-
root._gaq = root._gaq || [];
|
|
110
|
-
|
|
111
114
|
// Useful for debugging:
|
|
112
|
-
// console.log(
|
|
113
|
-
|
|
115
|
+
// console.log(eventAnalytics);
|
|
116
|
+
|
|
114
117
|
if (typeof root.ga === "function") {
|
|
115
118
|
root.ga('send', eventAnalytics);
|
|
116
119
|
}
|
|
@@ -91,5 +91,16 @@
|
|
|
91
91
|
</footer>
|
|
92
92
|
</section>
|
|
93
93
|
<%= yield :body_end %>
|
|
94
|
+
<% if Rails.env.production? %>
|
|
95
|
+
<script class="analytics">
|
|
96
|
+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
|
97
|
+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
|
98
|
+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
|
99
|
+
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
|
100
|
+
|
|
101
|
+
ga('create', 'UA-26179049-6', 'alphagov.co.uk');
|
|
102
|
+
ga('send', 'pageview');
|
|
103
|
+
</script>
|
|
104
|
+
<% end %>
|
|
94
105
|
</body>
|
|
95
106
|
</html>
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: govuk_admin_template
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- GOV.UK Dev
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-02-
|
|
11
|
+
date: 2015-02-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|