Tuesday, June 26, 2018

PeopleTools - Opt-out option for Google Analytics

With GDPR taking effect on May 25th 2018, an "opt-out" option for tracking cookies is a prevalent topic in many forums. This post is not intended to provide guidance for GDPR compliance. FWIW, before implementing anything at the PeopleTools layer, we must first consider the privacy policy implications at a much broader organizational level.

That said, I have written several posts on how to implement Google Analytics in PeopleTools. The most recent approach uses gtag.js.
PeopleTools - Using Google Analytics (gtag.js)

This post describes a proof of concept to extend the gtag.js implementation to provide a simple "opt-out" feature for end users using client side code (javascript).

Demo

In the following video, we can see that the user selects the "opt-out" option and the custom opt-out cookie is created. Any subsequent requests will not be tracked in Google Analytics.


Google Analytics Real-Time Data


In the following video, we can see that the user dismisses the "opt-out" option and the custom opt-out cookie is not created. Any subsequent requests will continue to be tracked in Google Analytics.


Google Analytics Real-Time Data


Script for reference

Notes

- This version of javascript, identifies the existence of Google Analytics related cookies to check if the session is new.
- If the session is new, a popup message is displayed to the end user. The message also provides a link to "opt-out" of Google Analytics. For the purposes of this demo, I used the delivered ptSetConfirmationMessage and ptCloseConfirmation javascript functions (which are part of PT_UTIL_BASIC HTML object) to display this message.
- If the user chooses to "opt-out" of Google Analytics, the following window property is set to true.
window['ga-disable-UA-XXXXXX-Y'] = true;
- Additionally, a custom cookie (ga-disable-UA-XXXXXXXX-Y) is created to identify this choice for subsequent requests.
- This cookie preference/choice will persist as long as this custom cookie is present.

This proof of concept is only intended to provide implementation ideas. You will most certainly need to tweak this code based on your organization's privacy policy.

Useful Resources

https://developers.google.com/analytics/devguides/collection/analyticsjs/user-opt-out
https://developers.google.com/analytics/devguides/collection/gajs/
https://www.robert-matthees.de/datenschutz-cookies/

Related Posts

Implementing Google Analytics in PeopleTools using gtag.js
Implementing Google Analytics in PeopleTools using analytics.js
Implementing Google Analytics in PeopleTools using ga.js

7 comments:

  1. More great GA stuff.
    Thanks Sasank.

    Tom

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Hello Sasank,
    Can we implement face detection in peoplesoft in image upload?

    ReplyDelete
    Replies
    1. Hi Ashish - I am not sure what you are trying to implement. Are you implementing face detection for PeopleSoft login process?

      I have not tried something like that, so I am not sure how we can implement such a feature.

      Delete
  4. Hi sasank,
    We are planning to upload and image for student and emoloyee in some component but at tye same time we want to validate that this photo has face or not.
    Example if someone uploaded a car's photo then we can show them message that invalid photo. No face detected

    ReplyDelete
    Replies
    1. Oh... Very cool. Sounds like a fun project.

      I will let you know if I get any ideas. You do the same! :)

      Delete