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

Remove dap-hacks.js and auto-track outbound links & downloads ourselves #1853

merged 2 commits into from May 3, 2018


None yet
2 participants

toolness commented May 3, 2018

Note: this is a PR against #1852, not develop.

This builds on #1852 and attempts to simplify our codebase and our GA setup by getting rid of dap-hacks.js (introduced in #916) and auto-tracking outbound links and downloads ourselves. The resulting implementation is less complicated than our DAP hacks, and also less coupled to DAP (which could change in the future). It also ensures that the same outbound link/download events are tracked in both the TTS GA account and DAP (before, these sorts of events were only tracked in DAP).

Once this is merged, adding documentation for GA (#847) will be much easier because our GA setup will be much easier to explain, and folks will largely be able to analyze the same kinds of behavior from either GA account.


  • While we're tracking outbound links in a similar way as DAP, we're not tracking downloads in a similar way: DAP tracks downloads by looking at a URL's file extension, but CALC (and many other websites) don't necessarily follow this convention; for instance, CALC's CSV download is at /api/rates/csv and has no .csv extension.

  • DAP does track mailto: links but our implementation doesn't. I figure this is OK since we're not terribly concerned with this metric, though we can easily add support for it if needed.

  • This PR disables DAP's auto-tracking, to avoid double counting. This is done by adding autotracker=false to DAP's querystring, as documented in DAP Code Capabilities Summary & Reference.

  • It was helpful while writing this to consult DAP's _initAutoTracker method.

  • Oh, weird. Looking at DAP's _initAutoTracker method, I'm now noticing that even though digital-analytics-program/gov-wide-code#48 hasn't been merged, its actual content was part of digital-analytics-program/gov-wide-code@84a8e2c. Which means that we could get rid of most of dap-hacks.js anyways... But still, I think there's enough advantages in just doing the auto-tracking ourselves that this PR is still worth it.

To do

  • Add tests.

@toolness toolness changed the title from [WIP] Remove dap-hacks.js and auto-track outbound links & downloads ourselves to Remove dap-hacks.js and auto-track outbound links & downloads ourselves May 3, 2018

@toolness toolness requested a review from hbillings May 3, 2018


I'm not super familiar with DAP, but this seems to make sense just from a JS perspective.

@toolness toolness merged commit 442f477 into dap-virtual-pageviews May 3, 2018

1 check passed

ci/circleci: build Your tests passed on CircleCI!

@toolness toolness deleted the remove-dap-hacks branch May 3, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment