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

Port analytics API from static #162

Merged
merged 8 commits into from
Mar 10, 2015
Merged

Port analytics API from static #162

merged 8 commits into from
Mar 10, 2015

Conversation

fofr
Copy link
Contributor

@fofr fofr commented Mar 10, 2015

Moved the new analytics library, javascript error tracking and print intent tracking from static so it can be easily used in non-rails projects.

Original PR for analytics library: alphagov/static#549
Earlier closed PR for context: #160

Changes from the static version:

  • dependencies on jQuery removed
  • dependency on the .bind polyfill removed
  • Tracker made more generic
    • GOVUK specific custom dimensions removed
    • Pageview tracking happens within the init so that apps can set custom dimensions beforehand

Also included:

  • The tests for analytics used Jasmine 2 so it made sense to upgrade the existing frontend_toolkit tests to use that.
  • Included a sample init to be copied into your own project as GA account IDs should not be stored in this repo.
  • Documentation

jonnywyatt and others added 6 commits March 10, 2015 11:30
Include sample init file.
Remove jQuery dependency from Tracker
Custom variables and dimensions need to be configured before the
initial page view is tracked. Rather than specifying a callback
function (which suggests an asynchronous behaviour), remove the
pageview tracking and let apps call it when they’re ready.

* Update the example to indicate that the pageview is needed
Include details about how to create and use the analytics API

* Detail caveats about custom variable and dimension indexes
* Include example of when to set custom dimensions in example
* Outline when to instantiate the tracker
* Detail the public API
});

// Set custom dimensions before tracking pageviews
// GOVUK.analytics.setDimension(…)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it worth adding to the comment, the URL to the doc section about using setDimension? Just so they know which params to pass to it.

@jonnywyatt
Copy link
Contributor

👍 Really good documentation

@edds
Copy link
Contributor

edds commented Mar 10, 2015

I would remove the javascripts/govuk/analytics/example-init/example-init.js. It is a duplicate of what is in the docs and has the potential to diverge from the docs. Having it held within the docs will reduce the potential for this divergence.

Can you add some documentation around the two files which aren't mentioned (print tracking and error reporting) what they do and how they should be used.

The formatting of the list in the "Create an analytics tracker" section of the docs is slightly broken. I think you are missing a blank line.

@jonnywyatt
Copy link
Contributor

Agreed the example is duplicated but if you were going to keep one copy wouldn't it be the file, for convenience and clarity of copying it out? The annotations from the readme could move into it as code comments?

@edds
Copy link
Contributor

edds commented Mar 10, 2015

I don't think that the example should live with the code in the javascripts/govuk/analytics folder. If it wants to live as a separate file it should live in the docs folder. Having example code next to real code is is a mix of concerns that shouldn't really exist. Personally I think it works best in the markdown document file so there is a single place which explains how to do everything. There is already code in the docs you would want to copy paste out if you were setting this up in a new project.

@jonnywyatt
Copy link
Contributor

Yep, agreed it should go under docs. I'd say a separate file is clearer but up to you guys :)

Keep a canonical example that can be copy and pasted within the
analytics documentation.

* Include link to docs from within tracker.js
* Remove old example-init.js
@fofr
Copy link
Contributor Author

fofr commented Mar 10, 2015

Updated in bff50a4 to have a single canonical init example within the docs, also linked to from the source file. Also added a brief bit about print and error tracking.

@tombye
Copy link
Contributor

tombye commented Mar 10, 2015

This is a great pull request, really detailed but easy to read and understand 👍

@jonnywyatt There is a mention of the lack of dependencies in the analytics page of the docs: https://github.com/alphagov/govuk_frontend_toolkit/pull/162/files#diff-a18afd2d1d40d1e6a39ba0d5f8fc18ddR21.

@dsingleton
Copy link
Contributor

👍

@fofr
Copy link
Contributor Author

fofr commented Mar 10, 2015

Is this good to merge?

edds added a commit that referenced this pull request Mar 10, 2015
Port analytics API from static
@edds edds merged commit f46e2e2 into master Mar 10, 2015
@edds edds deleted the analytics branch March 10, 2015 16:35
@fofr fofr mentioned this pull request Mar 10, 2015
fofr added a commit to alphagov/static that referenced this pull request Mar 11, 2015
* Pick up analytics scripts which have been ported to the toolkit in:
alphagov/govuk_frontend_toolkit#162
gemmaleigh pushed a commit to alphagov/govuk_elements that referenced this pull request Apr 10, 2015
# 3.3.0

- Add: Analytics - pageview tracking for a print attempt

# 3.2.1

- Fix: Analytics - don't run error and print plugins on load

# 3.2.0

- Add: Analytics API
alphagov/govuk_frontend_toolkit#162
https://github.com/alphagov/govuk_frontend_toolkit/blob/master/docs/anal
ytics.md
gemmaleigh added a commit to alphagov/service-manual-frontend that referenced this pull request Apr 25, 2016
# 4.10.0

- Allow New Transport font stack to be overridden by apps using
`$toolkit-font-stack`
and `$toolkit-font-stack-tabular` (PR #230)

# 4.9.1

- Fix phase banner alignment (PR #266)

# 4.9.0

- Add websafe organisation colours
- Split colours into two files with backwards-compatible colours.scss
replacement

# 4.8.2

- Add GOV.UK lint to lint scss files (PR #260)
- Remove reference to old colour palette (PR #256)
- Fix link to GOV.UK elements - tabular data

# 4.8.1

- Update DEFRA brand colour to new green (PR #249)

# 4.8.0

- Pass cohort name to analytics when using multivariate test (PR #251)

# 4.7.0

- Add 'mailto' tracking to GOV.UK Analytics (PR #244)

# 4.6.1

- Use the Sass variable $light-blue for link active and hover colours
(PR #242)

# 4.6.0

- Add breadcrumb styles, separator images and documentation (PR #236)
- Add fallback image for the back link (PR #235)

# 4.5.0

- Find and auto-start JavaScript modules from markup:
`data-module="module-name"`(PR #227)

# 4.4.0

- Add helpers partial for functions
- Add px to em function and documentation

# 4.3.0

- Allow javascript error tracking to be filtered to avoid noise from
plugins

# 4.2.1

- Track download links using events not pageviews

# 4.2.0

- Add two analytics plugins for download and external link tracking
- Update typography mixins to be mobile first (PR #157)

# 4.1.1

- Update Accessible Media Player to remove dependency on $.browser (PR
#206)

# 4.1.0

- Add support for sending the `page` option to
`GOVUK.analytics.trackEvent` (PR #203)

# 4.0.1

- Fix: stop multiline text from dropping below phase tag.

# 4.0.0

- Remove Google Analytics classic
alphagov/govuk_frontend_toolkit#194
  - References to google-analytics-classic-tracker.js should be removed
- Rename GOVUK.Tracker to GOVUK.Analytics
  - References to GOVUK.Tracker should be updated

# 3.5.1

- Changes Analytics API library to accept one, both or neither of the
analytics tracking codes. This means we can start removing classic
tracking codes from apps.

#3.5.0

- Adds cross domain tracking to Analytics API library:
alphagov/govuk_frontend_toolkit#185
- Adds sass variables for discovery and live phases

#3.4.2

- Fix: Before this fix, when a user fell into variant 0 of a
multivariate test,
the data wouldn't be reported to Google correctly because of a broken
null check in the code block that opts the user into the Google Content
Experiment.

# 3.4.1

- Fix: Make the error colour a darker red for greater contrast and to
meet WCAG 2.0 AAAA
(this was meant to go into 3.3.1 but was lost from history)
- Add `$focus-colour` variable (#180)

# 3.4.0

- multivariate-test.js: add support for using Google Content
Experiments as the reporting
backend for multivariate tests

# 3.3.1

- Fix: Make the error colour a darker red for greater contrast and to
meet WCAG 2.0 AAAA

# 3.3.0

- Add: Analytics - pageview tracking for a print attempt

# 3.2.1

- Fix: Analytics - don't run error and print plugins on load

# 3.2.0

- Add: Analytics API
alphagov/govuk_frontend_toolkit#162
https://github.com/alphagov/govuk_frontend_toolkit/blob/master/docs/anal
ytics.md

# 3.1.0

- Fix: outdent to add right margin rather than only left
- Fix: add missing semi-colons in JavaScript files
- Fix: use box-sizing mixin in column mixin to support more browsers
- Add: ability to specify float direction on column mixin
- Add: Sass-lint tests

# 3.0.1

- Fix a bug with the npm publishing. npm requires a version change to
publish a package.

# 3.0.0

- Change publishing method to not use git submodules in
govuk_frontend_toolkit_npm.
  This is a major version bump because it will move the toolkit from
  `./node_modules/govuk_frontend_toolkit/govuk_frontend_toolkit/`
  to `./node_modules/govuk_frontend_toolkit/`, which will break
relative imports in Sass.
- Fix typo in Sass comment
gemmaleigh added a commit to alphagov/service-manual-frontend that referenced this pull request Apr 25, 2016
# 4.10.0

- Allow New Transport font stack to be overridden by apps using
`$toolkit-font-stack`
and `$toolkit-font-stack-tabular` (PR #230)

# 4.9.1

- Fix phase banner alignment (PR #266)

# 4.9.0

- Add websafe organisation colours
- Split colours into two files with backwards-compatible colours.scss
replacement

# 4.8.2

- Add GOV.UK lint to lint scss files (PR #260)
- Remove reference to old colour palette (PR #256)
- Fix link to GOV.UK elements - tabular data

# 4.8.1

- Update DEFRA brand colour to new green (PR #249)

# 4.8.0

- Pass cohort name to analytics when using multivariate test (PR #251)

# 4.7.0

- Add 'mailto' tracking to GOV.UK Analytics (PR #244)

# 4.6.1

- Use the Sass variable $light-blue for link active and hover colours
(PR #242)

# 4.6.0

- Add breadcrumb styles, separator images and documentation (PR #236)
- Add fallback image for the back link (PR #235)

# 4.5.0

- Find and auto-start JavaScript modules from markup:
`data-module="module-name"`(PR #227)

# 4.4.0

- Add helpers partial for functions
- Add px to em function and documentation

# 4.3.0

- Allow javascript error tracking to be filtered to avoid noise from
plugins

# 4.2.1

- Track download links using events not pageviews

# 4.2.0

- Add two analytics plugins for download and external link tracking
- Update typography mixins to be mobile first (PR #157)

# 4.1.1

- Update Accessible Media Player to remove dependency on $.browser (PR
#206)

# 4.1.0

- Add support for sending the `page` option to
`GOVUK.analytics.trackEvent` (PR #203)

# 4.0.1

- Fix: stop multiline text from dropping below phase tag.

# 4.0.0

- Remove Google Analytics classic
alphagov/govuk_frontend_toolkit#194
  - References to google-analytics-classic-tracker.js should be removed
- Rename GOVUK.Tracker to GOVUK.Analytics
  - References to GOVUK.Tracker should be updated

# 3.5.1

- Changes Analytics API library to accept one, both or neither of the
analytics tracking codes. This means we can start removing classic
tracking codes from apps.

#3.5.0

- Adds cross domain tracking to Analytics API library:
alphagov/govuk_frontend_toolkit#185
- Adds sass variables for discovery and live phases

#3.4.2

- Fix: Before this fix, when a user fell into variant 0 of a
multivariate test,
the data wouldn't be reported to Google correctly because of a broken
null check in the code block that opts the user into the Google Content
Experiment.

# 3.4.1

- Fix: Make the error colour a darker red for greater contrast and to
meet WCAG 2.0 AAAA
(this was meant to go into 3.3.1 but was lost from history)
- Add `$focus-colour` variable (#180)

# 3.4.0

- multivariate-test.js: add support for using Google Content
Experiments as the reporting
backend for multivariate tests

# 3.3.1

- Fix: Make the error colour a darker red for greater contrast and to
meet WCAG 2.0 AAAA

# 3.3.0

- Add: Analytics - pageview tracking for a print attempt

# 3.2.1

- Fix: Analytics - don't run error and print plugins on load

# 3.2.0

- Add: Analytics API
alphagov/govuk_frontend_toolkit#162
https://github.com/alphagov/govuk_frontend_toolkit/blob/master/docs/anal
ytics.md

# 3.1.0

- Fix: outdent to add right margin rather than only left
- Fix: add missing semi-colons in JavaScript files
- Fix: use box-sizing mixin in column mixin to support more browsers
- Add: ability to specify float direction on column mixin
- Add: Sass-lint tests

# 3.0.1

- Fix a bug with the npm publishing. npm requires a version change to
publish a package.

# 3.0.0

- Change publishing method to not use git submodules in
govuk_frontend_toolkit_npm.
  This is a major version bump because it will move the toolkit from
  `./node_modules/govuk_frontend_toolkit/govuk_frontend_toolkit/`
  to `./node_modules/govuk_frontend_toolkit/`, which will break
relative imports in Sass.
- Fix typo in Sass comment
gemmaleigh added a commit to alphagov/service-manual-frontend that referenced this pull request Apr 26, 2016
# 4.10.0

- Allow New Transport font stack to be overridden by apps using
`$toolkit-font-stack`
and `$toolkit-font-stack-tabular` (PR #230)

# 4.9.1

- Fix phase banner alignment (PR #266)

# 4.9.0

- Add websafe organisation colours
- Split colours into two files with backwards-compatible colours.scss
replacement

# 4.8.2

- Add GOV.UK lint to lint scss files (PR #260)
- Remove reference to old colour palette (PR #256)
- Fix link to GOV.UK elements - tabular data

# 4.8.1

- Update DEFRA brand colour to new green (PR #249)

# 4.8.0

- Pass cohort name to analytics when using multivariate test (PR #251)

# 4.7.0

- Add 'mailto' tracking to GOV.UK Analytics (PR #244)

# 4.6.1

- Use the Sass variable $light-blue for link active and hover colours
(PR #242)

# 4.6.0

- Add breadcrumb styles, separator images and documentation (PR #236)
- Add fallback image for the back link (PR #235)

# 4.5.0

- Find and auto-start JavaScript modules from markup:
`data-module="module-name"`(PR #227)

# 4.4.0

- Add helpers partial for functions
- Add px to em function and documentation

# 4.3.0

- Allow javascript error tracking to be filtered to avoid noise from
plugins

# 4.2.1

- Track download links using events not pageviews

# 4.2.0

- Add two analytics plugins for download and external link tracking
- Update typography mixins to be mobile first (PR #157)

# 4.1.1

- Update Accessible Media Player to remove dependency on $.browser (PR
#206)

# 4.1.0

- Add support for sending the `page` option to
`GOVUK.analytics.trackEvent` (PR #203)

# 4.0.1

- Fix: stop multiline text from dropping below phase tag.

# 4.0.0

- Remove Google Analytics classic
alphagov/govuk_frontend_toolkit#194
  - References to google-analytics-classic-tracker.js should be removed
- Rename GOVUK.Tracker to GOVUK.Analytics
  - References to GOVUK.Tracker should be updated

# 3.5.1

- Changes Analytics API library to accept one, both or neither of the
analytics tracking codes. This means we can start removing classic
tracking codes from apps.

#3.5.0

- Adds cross domain tracking to Analytics API library:
alphagov/govuk_frontend_toolkit#185
- Adds sass variables for discovery and live phases

#3.4.2

- Fix: Before this fix, when a user fell into variant 0 of a
multivariate test,
the data wouldn't be reported to Google correctly because of a broken
null check in the code block that opts the user into the Google Content
Experiment.

# 3.4.1

- Fix: Make the error colour a darker red for greater contrast and to
meet WCAG 2.0 AAAA
(this was meant to go into 3.3.1 but was lost from history)
- Add `$focus-colour` variable (#180)

# 3.4.0

- multivariate-test.js: add support for using Google Content
Experiments as the reporting
backend for multivariate tests

# 3.3.1

- Fix: Make the error colour a darker red for greater contrast and to
meet WCAG 2.0 AAAA

# 3.3.0

- Add: Analytics - pageview tracking for a print attempt

# 3.2.1

- Fix: Analytics - don't run error and print plugins on load

# 3.2.0

- Add: Analytics API
alphagov/govuk_frontend_toolkit#162
https://github.com/alphagov/govuk_frontend_toolkit/blob/master/docs/anal
ytics.md

# 3.1.0

- Fix: outdent to add right margin rather than only left
- Fix: add missing semi-colons in JavaScript files
- Fix: use box-sizing mixin in column mixin to support more browsers
- Add: ability to specify float direction on column mixin
- Add: Sass-lint tests

# 3.0.1

- Fix a bug with the npm publishing. npm requires a version change to
publish a package.

# 3.0.0

- Change publishing method to not use git submodules in
govuk_frontend_toolkit_npm.
  This is a major version bump because it will move the toolkit from
  `./node_modules/govuk_frontend_toolkit/govuk_frontend_toolkit/`
  to `./node_modules/govuk_frontend_toolkit/`, which will break
relative imports in Sass.
- Fix typo in Sass comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants