Skip to content

Commit

Permalink
Merge pull request #977 from alphagov/default-nav-doc-type
Browse files Browse the repository at this point in the history
Track the navigation document type for all pages
  • Loading branch information
suzannehamilton authored Mar 31, 2017
2 parents 7d93956 + d2af3ea commit c51c169
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/assets/javascripts/analytics/static-analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
this.setThemesDimension(dimensions['themes']);
this.setNavigationPageTypeDimension(dimensions['navigation-page-type']);
this.setUserJourneyStage(dimensions['user-journey-stage']);
this.setNavigationDocumentTypeDimension(dimensions['navigation-document-type']);
};

StaticAnalytics.prototype.setDimensionsThatDoNotHaveDefaultValues = function(dimensions) {
Expand All @@ -113,7 +114,6 @@
this.setOrganisationsDimension(dimensions['analytics:organisations']);
this.setWorldLocationsDimension(dimensions['analytics:world-locations']);
this.setRenderingApplicationDimension(dimensions['rendering-application']);
this.setNavigationDocumentTypeDimension(dimensions['navigation-document-type']);
};

StaticAnalytics.prototype.setAbTestDimensionsFromMetaTags = function() {
Expand Down Expand Up @@ -210,7 +210,7 @@
};

StaticAnalytics.prototype.setNavigationDocumentTypeDimension = function(documentType) {
this.setDimension(34, documentType);
this.setDimension(34, documentType || "other");
};

GOVUK.StaticAnalytics = StaticAnalytics;
Expand Down
10 changes: 7 additions & 3 deletions spec/javascripts/analytics/static-analytics-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe("GOVUK.StaticAnalytics", function() {

describe('when created', function() {
// The number of setup arguments which are set before the dimensions
const expectedDefaultArgumentCount = 8;
const expectedDefaultArgumentCount = 9;

var universalSetupArguments;

Expand Down Expand Up @@ -64,7 +64,6 @@ describe("GOVUK.StaticAnalytics", function() {
<meta name="govuk:political-status" content="historic">\
<meta name="govuk:analytics:organisations" content="<D10>">\
<meta name="govuk:analytics:world-locations" content="<W1>">\
<meta name="govuk:navigation-document-type" content="guidance">\
');

analytics = new GOVUK.StaticAnalytics({universalId: 'universal-id'});
Expand All @@ -77,7 +76,6 @@ describe("GOVUK.StaticAnalytics", function() {
expect(setupArguments[4]).toEqual(['set', 'dimension7', 'historic']);
expect(setupArguments[5]).toEqual(['set', 'dimension9', '<D10>']);
expect(setupArguments[6]).toEqual(['set', 'dimension10', '<W1>']);
expect(setupArguments[7]).toEqual(['set', 'dimension34', 'guidance']);
});

it('ignores meta tags not set', function() {
Expand Down Expand Up @@ -149,6 +147,12 @@ describe("GOVUK.StaticAnalytics", function() {
number: 33,
defaultValue: 'thing',
setupArgumentsIndex: 7
},
{
name: 'navigation-document-type',
number: 34,
defaultValue: 'other',
setupArgumentsIndex: 8
}
].forEach(function (dimension) {
it('sets the ' + dimension.name + ' dimension from a meta tag if present', function () {
Expand Down

0 comments on commit c51c169

Please sign in to comment.