Uploaded image for project: 'Planet4'
  1. Planet4
  2. PLANET-6223

Implement Google's Consent Mode

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Accepted
    • Icon: Should have Should have
    • 2.64.0
    • None

      Context:

      One of the recommendations from the GDPR & Cookies 2021 investigation is to apply Google's Consent Mode on Planet 4. We need an evaluation from the development team regarding the feasibility and easiness of this implementation. 

      User Stories:

      Follow the table below to configure Google's Consent Mode according to user's preferences:

      Action User story consent analytics_storage  ad_storage  dataLayer event
      Default Consent When the user lands on the website default denied denied defaultConsent
      Update Consent When the user accepts the cookies banner or when the user manually allow both types of tracking (at the Privacy page) update granted granted updateConsent
      Update Consent When the user allows only Planet 4 necessary cookies update denied denied updateConsent
      Update Consent When the user allows only analytics tracking update granted denied updateConsent
       
      Update Consent When the user allows only advertising tracking update denied granted updateConsent
      Update Consent When the user manually removes all types of tracking (manually at Privacy page) update denied denied updateConsent
       

       

       

       Note: Important to keep the existing dataLayer event 'cookiesConsent' when the user clicks in the "Got it" button. We are using this event to track clicks in Google Analytics. 

      Task: 

      STEP 1: SET UP GOOGLE CONSENT MODE ON PLANET 4

      Consent-aware tag behavior must be configured on every page of your website. On each page, there are usually two points where this is configured:

      1. On page load
        When the page loads, you should only use measurement capabilities that align with your users expectations. This is configured through the gtag('consent', 'default', ...) command.
      1. After visitor provides a consent status, or if consent status is known
        After the visitor provides their consent status (or if it was persisisted from a previous page load), enable the measurement features they have consented to (such as reading/writing cookies) through the gtag('consent', 'update', ...) command.

      Configure default behavior

      To adjust the default measurement capabilities, you will need to do the following on every page of your site before any tags fire:

      1. Ensure the dataLayer variable is defined.
      2. Ensure the gtag function is defined.
      3. Use the gtag('consent', ...) command to set the measurement capabilities.
      4. Send a default_consent event using dataLayer.push.

      For example, to deny ad_storage and analytics_storage by default:

      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      
      gtag('consent', 'default', {
        'ad_storage': 'denied',
        'analytics_storage': 'denied'
      });
      
      dataLayer.push({
        'event': 'default_consent'
      });

      This will set the default values for 'ad_storage' and 'analytics_storage' to 'denied'. For full details on supported keys see consent in the API reference.

      Note: If you don't explicitly set a capability to 'denied', it will default to 'granted'.

      Update behavior

      When your users provide consent, commonly through interacting with a consent banner, or their consent status is known from a previous page load, update your tags behavior with the gtag('consent', 'update', ...) command. For example, for a user that has granted consent to use advertising cookies:

      gtag('consent', 'update', {
        'ad_storage': 'granted'
      });
      

      Only fields that are provided to the update call will be changed. Above, only the 'ad_storage' value was changed. If 'analytics_storage' was set to 'denied' (like in configure default behavior), it would still be denied after this call. It is up to you to ensure the correct values are set for all consent keys. For full details on supported keys, see consent in the API reference.

      This command should be called as soon as possible on every page. After the user indicates their consent, you should persist their choice and call the update command accordingly on subsequent pages.

      SEE AN IMPLEMENTATION EXAMPLE HERE

      STEP 2: CREATE A SETTING TO ENABLE/DISABLE THE CONSENT MODE

      Once implemented, the Consent Mode will immediately start working with all Google’s tags implemented via Google Tag Manager. This will potentially cause disruptions to the collection of data on both the global and local Google Analytics properties. 

      With this in mind, we shouldn’t enforce this solution to all websites by default. We should recommend NROs to apply these settings, but every local office should do their own due diligence and decide whether or not to follow our recommendations. 

      A solution for this would be to create a checkbox on Planet 4 analytics settings to enable or disable the entire implementation of Google’s Consent Mode. Example:

      [X] Enable Google’s Consent Mode mechanism 

      --> Make sure to purge CloudFlare cache (if needed)

      ------------------------------------------

      Extra resources

      Questions to consider: 

      • How long it would take to implement Google's Consent Mode to Planet 4 consent mechanism? 
      • Are there any disadvantages to this solution? 
      • How feasible it is to make the entire implementation optional for admins (create a new setting on Planet 4 Analytics that enables/disables this implementation)?

      Sources:

       

            mleray Maud Leray
            jmarubay Julia Marubayashi
            Julia Marubayashi Julia Marubayashi
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: