Skip to main content

UTMSimple Consent Mode Guide (GDPR)

UTMSimple now supports conditional consent mode that integrates seamlessly with Google Tag Manager (GTM) and other consent management systems.

How It Works

When UTMSIMPLE_CONSENT_MODE = true is set globally, UTMSimple will not automatically initialize. Instead, you can manually call HandL.init() when consent is granted.

Basic Implementation

Set the global flag before loading UTMSimple:

<script>
    window.UTMSIMPLE_CONSENT_MODE = true;
</script>
<script src="path/to/utmsimple.js"></script>

2. Initialize When Consent is Granted

// When user grants consent
window.UTMSIMPLE_CONSENT_MODE = false;
HandL.init();

GTM Integration

Method 1: Using GTM Variables and Triggers

  1. Create a GTM Variable for consent status:

    • Variable Type: Custom JavaScript
    • Code: return window.UTMSIMPLE_CONSENT_MODE || false;
  2. Create a Trigger for consent granted:

    • Trigger Type: Custom Event
    • Event Name: consent_granted
    • Or use GTM's built-in consent mode triggers
  3. Create a Custom HTML Tag to initialize UTMSimple:

    <script>
    if (typeof HandL !== 'undefined') {
        window.UTMSIMPLE_CONSENT_MODE = false;
        HandL.init();
    }
    </script>
    

Method 2: Using GTM Consent Mode

Advanced Usage

UTMSimple provides a method to delete all cookies it has created:

// Delete all UTMSimple cookies and localStorage data
const result = HandL.deleteAllCookies();

// Result object contains:
// - deletedCount: number of cookies deleted
// - cookiesDeleted: array of cookie names that were deleted

This method:

  • Deletes all UTM parameter cookies
  • Deletes first-touch parameter cookies
  • Deletes UTMSimple-specific cookies (handlID, handl_js_domain, etc.)
  • Clears localStorage items used for Facebook advanced matching
  • Fires a UTMSimpleCookiesDeleted event
  • Returns a result object with deletion details

Event Listeners

UTMSimple fires custom events that you can listen to:

// Listen for successful initialization
document.addEventListener('UTMSimpleLoaded', function() {
    console.log('UTMSimple loaded successfully');
});

// Listen for cookie setting
document.addEventListener('UTMSimpleCookiesSet', function() {
    console.log('UTMSimple cookies have been set');
});

// Listen for cookie deletion
document.addEventListener('UTMSimpleCookiesDeleted', function(event) {
    console.log(`UTMSimple cookies deleted: ${event.detail.deletedCount} cookies removed`);
});

Example Implementation

Best Practices

Troubleshooting

Script Not Initializing

  • Check if UTMSIMPLE_CONSENT_MODE is set to true
  • Ensure HandL.init() is called after consent is granted
  • Verify UTMSimple script is loaded before calling HandL.init()

GTM Integration Issues

  • Ensure GTM variables are properly configured
  • Check trigger conditions match your consent logic
  • Verify custom HTML tags are firing at the right time

Console Errors

  • Look for "Consent mode enabled" messages in console
  • Check for "HandL not available" warnings
  • Ensure all dependencies are loaded