Google Analytics Data Consent Settings for OpenCart and Journal3 template users

This article is for OpenCart and Journal3 Users who use Journal3’s cookie notification feature.

You need to use the following script in your Google Analytics Field. (Making ID changes as required)

<script>
// Define dataLayer and the gtag function.
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}

// Set default consent to 'denied' as a placeholder
// Determine actual values based on your own requirements
gtag('consent', 'default', {
  'ad_storage': 'denied',
  'ad_user_data': 'denied',
  'ad_personalization': 'denied',
  'analytics_storage': 'denied'
});
</script>

<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXX"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-XXXXXXX');
gtag('config', 'AW-12345678');
</script>

<script>
  function consentGrantedAdStorage() {
    console.log("consentGrantedAdStorage function triggered!");
    gtag('consent', 'update', {
      'ad_storage': 'granted',
  'ad_user_data': 'granted',
  'ad_personalization': 'granted',
  'analytics_storage': 'granted'
    });
  }

  // Ensure that the script runs after the document is ready
  $(document).ready(function() {
    $('.notification-close').on('click', consentGrantedAdStorage);
  });
</script>

If the implementation is done correctly, wait for 24 to 48 hours for those updates to show on Google