digital-analytics-program / gov-wide-code

Provides a set of javascript files and documentation to implement web analytics on US federal websites
http://www.digital.gov/dap
104 stars 55 forks source link

Add option to skip sending the initial pageview #63

Closed GUI closed 1 year ago

GUI commented 6 years ago

This adds a sendpageview option to the URL parameters, which defaults to true (the current behavior, so this shouldn't change existing usage), but can be set to false to skip sending the initial pageview command to Google Analytics on page load.

The use-case I have for this is in dealing with integrating DAP with some single-page JavaScript apps where I'm also wanting to send virtual pageviews (similar to https://github.com/digital-analytics-program/gov-wide-code/issues/59). The problem is that the simplest ways to integrate virtual page views in these type of apps may lead to double counting the initial pageview, since DAP always sends a pageview, and these type of javascript routers may also send a virtual pageview on load. While there are ways to workaround this within the applications, having something like this type of toggle might be handy. This way you can opt-out of DAP's initial pageview if you know you only want to be performing virtual pageviews within your own application.

Give a shout if you have any questions or comments. Thanks!

tdlowden commented 6 years ago

Thanks! We'll evaluate adding this to next version.

smarina04 commented 1 year ago

This references an old version of the DAP code, no longer applies to the latest code.