diff --git a/app/assets/javascripts/analytics/custom-dimensions.js b/app/assets/javascripts/analytics/custom-dimensions.js index 59d808548..9e9f8281a 100644 --- a/app/assets/javascripts/analytics/custom-dimensions.js +++ b/app/assets/javascripts/analytics/custom-dimensions.js @@ -125,6 +125,8 @@ var policyAreaLinks = $('section.document-block a').length + $('section .collection-list h2 a').length + var whitehallFinderPageLinks = + $('.document-list .document-row h3 a').length; var linksCount = relatedLinks || @@ -133,7 +135,8 @@ leafLinks || browsePageLinks || topicPageLinks || - policyAreaLinks; + policyAreaLinks || + whitehallFinderPageLinks; return linksCount; } diff --git a/spec/javascripts/analytics/static-analytics-spec.js b/spec/javascripts/analytics/static-analytics-spec.js index f4cdc59f8..c583678e2 100644 --- a/spec/javascripts/analytics/static-analytics-spec.js +++ b/spec/javascripts/analytics/static-analytics-spec.js @@ -706,6 +706,53 @@ describe("GOVUK.StaticAnalytics", function() { expect(pageViewObject.dimension26).toEqual('2'); }); }); + + describe('on a whitehall finder page (e.g Announcements)', function() { + beforeEach(function() { + $('body').append('\ +
\ +
    \ +
  1. \ +

    \ + \ + Creative sector receives record boost of £700 million pounds\ + \ +

    \ +
  2. \ +
  3. \ +

    \ + \ + Dangerous occurrence at Broad Oak level crossing\ + \ +

    \ +
  4. \ +
  5. \ +

    \ + \ + Outbreaks of Koi herpesvirus (KHV) disease in 2017\ + \ +

    \ +
  6. \ +
\ + '); + }); + + afterEach(function() { + $('.test-fixture').remove(); + }); + + it('tracks the number of sections', function() { + analytics = new GOVUK.StaticAnalytics({universalId: 'universal-id'}); + pageViewObject = getPageViewObject(); + expect(pageViewObject.dimension26).toEqual('0'); + }); + + it('tracks the total number of links', function() { + analytics = new GOVUK.StaticAnalytics({universalId: 'universal-id'}); + pageViewObject = getPageViewObject(); + expect(pageViewObject.dimension27).toEqual('3'); + }); + }); }); });