Skip to content

Commit

Permalink
Merge pull request #429 from alphagov/fix-non-interaction-flag-for-sc…
Browse files Browse the repository at this point in the history
…roll-tracking

Repair 'fix' for analytics scroll tracker non-interaction flag
  • Loading branch information
dsingleton committed Jun 30, 2014
2 parents 923355b + 33a96fb commit b33b8e6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/assets/javascripts/analytics/scroll-tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
for ( var i=0; i<this.trackedNodes.length; i++ ) {
if ( this.trackedNodes[i].isVisible() && !this.trackedNodes[i].alreadySeen ) {
this.trackedNodes[i].alreadySeen = true;
GOVUK.sendToAnalytics(["_trackEvent"].concat(this.trackedNodes[i].eventData).concat([true]));
GOVUK.sendToAnalytics(["_trackEvent"].concat(this.trackedNodes[i].eventData).concat([0, true]));
// Last 'true' sets non-interaction flag
// https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide#non-interaction
}
Expand Down
8 changes: 4 additions & 4 deletions spec/javascripts/analytics/scroll-tracker-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ describe("GOVUK.ScrollTracker", function() {
scrollToPercent(60);

expect(GOVUK.sendToAnalytics.calls.count()).toBe(2);
expect(GOVUK.sendToAnalytics.calls.argsFor(0)).toEqual([ ["_trackEvent", "ScrollTo", "Percent", "25", true] ]);
expect(GOVUK.sendToAnalytics.calls.argsFor(1)).toEqual([ ["_trackEvent", "ScrollTo", "Percent", "50", true] ]);
expect(GOVUK.sendToAnalytics.calls.argsFor(0)).toEqual([ ["_trackEvent", "ScrollTo", "Percent", "25", 0, true] ]);
expect(GOVUK.sendToAnalytics.calls.argsFor(1)).toEqual([ ["_trackEvent", "ScrollTo", "Percent", "50", 0, true] ]);
});
});

Expand All @@ -71,7 +71,7 @@ describe("GOVUK.ScrollTracker", function() {
scrollToShowHeadingNumber(1);

expect(GOVUK.sendToAnalytics.calls.count()).toBe(1);
expect(GOVUK.sendToAnalytics.calls.argsFor(0)).toEqual([ ["_trackEvent", "ScrollTo", "Heading", "This is the first heading", true] ]);
expect(GOVUK.sendToAnalytics.calls.argsFor(0)).toEqual([ ["_trackEvent", "ScrollTo", "Heading", "This is the first heading", 0, true] ]);

scrollToShowHeadingNumber(2);

Expand All @@ -80,7 +80,7 @@ describe("GOVUK.ScrollTracker", function() {
scrollToShowHeadingNumber(3);

expect(GOVUK.sendToAnalytics.calls.count()).toBe(2);
expect(GOVUK.sendToAnalytics.calls.argsFor(1)).toEqual([ ["_trackEvent", "ScrollTo", "Heading", "This is the third heading", true] ]);
expect(GOVUK.sendToAnalytics.calls.argsFor(1)).toEqual([ ["_trackEvent", "ScrollTo", "Heading", "This is the third heading", 0, true] ]);
});
});

Expand Down

0 comments on commit b33b8e6

Please sign in to comment.