Skip to content
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

Honor "Do Not Track" while still counting page views #68

Closed
alpipego opened this issue May 8, 2020 · 6 comments
Closed

Honor "Do Not Track" while still counting page views #68

alpipego opened this issue May 8, 2020 · 6 comments
Labels
enhancement New feature or request

Comments

@alpipego
Copy link
Contributor

alpipego commented May 8, 2020

When a user has turned on "Do Not Track", no pageviews get tracked at all.

My understanding of DNT is, to not "track" users, try to identify them, and analyze their behavior and not necessarily not to gather statistics.

The solution I propose: Do not set a cookie or gather a referrer when a user has DNT turned on but still record the impression.

alpipego added a commit to alpipego/koko-analytics that referenced this issue May 8, 2020
if a user has set Do Not Track, don't set a cookie (even if the setting
  is enabled) and don't try to get the referrer, fixes ibericode#68.
@dannyvankooten dannyvankooten added the enhancement New feature or request label May 12, 2020
@dannyvankooten
Copy link
Member

Hey @alpipego,

I'm afraid I can't merge this right away as it changes the default behavior of the plugin and in turn will effect statistics for people who've been running Koko Analytics for a while now. I also think it's debatable what doNotTrack actually means and what users want it to do, e.g. people might also use it to signal they don't want to waste any unnecessary bandwidth when data is limited (large parts of the world).

What we can do is make this configurable through a filter hook by adding a property to the window.koko_analytics configuration object. Would that work for you?

dannyvankooten added a commit that referenced this issue May 13, 2020
@alpipego
Copy link
Contributor Author

Hi Danny, thanks for your reply and the quick fix.

I should've kept the PR as "Draft" to show you that it was more an idea than a mergeable solution.

Your solution in 9d2e133 is not quite what I had in mind, as I'd like to honor "Do Not Track" (as in I don't want to connect two data points) but I still want to collect the pageview. If that's nothing you're interested in at the moment I'm fine with that.

@dannyvankooten
Copy link
Member

Hey @alpipego,

The main thing preventing me is that I don't see the value at this moment. All data that is stored is already completely anonymised and can in no way lead back to the visitor or connect two datapoints together. One could argue that there is no individual tracking going on anyway and we can just ignore DNT altogether (hence, the new filter).

Perhaps the following snippet is close to what you're intending to do?

window.koko_analytics.use_cookie = navigator.doNotTrack !== '1'

That will configure the plugin to only set a cookie when doNotTrack is disabled.

@alpipego
Copy link
Contributor Author

alpipego commented May 13, 2020

Thanks. The combination of the filter and the window.koko_analytics.use_cookie seem to do what I was trying to achieve. 🙌

@kamauwanjoroge
Copy link

Is there an easier way to implement this in my theme's functions.php? I would like to track the pageview but not set a cookie.

@alpipego
Copy link
Contributor Author

@askel45 add this to your functions.php:

add_filter('koko_analytics_honor_dnt', '__return_false');

add_action('wp_enqueue_scripts', function() {
    wp_add_inline_script('koko-analytics', 'window.koko_analytics.use_cookie = navigator.doNotTrack !== "1"', 'before');
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants