CookieHub Docs

Use development/stage mode on non-production domains

CookieHub requires the domain to match the one created in the dashboard to store user choices. When using CookieHub on a different domain, the consent dialog will appear on every page view since the choice isn't stored. This can be problematic in development and staging environments where a different top-level domain is used. The issue can be easily resolved when implementing CookieHub with Google Tag Manager. You can dynamically populate the "Production" property in the CookieHub tag using a variable that detects the hostname.

Follow these steps to ensure CookieHub operates in production mode only for the designated production domain, while using development mode for other domains:

  1. Log in to Google Tag Manager.
  2. Click on the "Variables" section on the left.
  3. Click the New button in "User-Defined variables"
  4. Choose "RegEx Table "as the variable type
  5. Select {{Page Hostname}} as the "Input Variable".
  6. In the RegEx Table, add a row and specify the production domain (e.g., cookiehub.com). Please note that special characters need to be escaped so put a backward slash in front of dots.
  7. Set the Output value for the pattern to true.
  8. Check the "Set Default Value" option and set the Default value to false.
  9. From the "Advanced Settings", uncheck both "Full Matches Only" and "Enable Capture Groups and Replacement Functionality".
  10. Provide a name for the new variable and save it. RegEx Table in Google Tag Manager
  11. Go to the "Tags" section and locate the CookieHub tag.
  12. Click the Edit icon to modify the tag configuration.
  13. Look for the "Production" field and select the newly created variable from the dropdown list.
  14. Save the changes to the CookieHub tag. Use development/stage mode on non-production domains
  15. Publish the changes in Google Tag Manager to make them live on your website.