Title: Javascript hook avoiding relad the page
Last modified: January 13, 2022

---

# Javascript hook avoiding relad the page

 *  [forna91](https://wordpress.org/support/users/forna91/)
 * (@forna91)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/javascript-hook-avoiding-relad-the-page/)
 * Hello,
 * I have a question, I use tag manager with consent mode and clarity with cookie
   disabled.
 * I can enable the use of cookie using a simple javascript script, but I dont know
   where put it, and this can help me avoiding the page reload every time.
 * Any idea?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [christophrado](https://wordpress.org/support/users/christophrado/)
 * (@christophrado)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/javascript-hook-avoiding-relad-the-page/#post-15247902)
 * Sorry, but it’s unclear to me how this is related to the plugin. Could you clarify
   on how you use Cookie Notice & Consent in that case?
 * It sounds as if this is a different use-case than what the plugin provides.
 *  Thread Starter [forna91](https://wordpress.org/support/users/forna91/)
 * (@forna91)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/javascript-hook-avoiding-relad-the-page/#post-15253128)
 * Yes I’ll try my best:
 * IF Google Tag Manager is used via js, when cookies are accepet, you can change
   the consent to store analytics data or ads data according to the cookie selected,
   as you can see here [gtm dev blog](https://developers.google.com/tag-platform/devguides/consent#tag-manager)
   the same for windows clarify, you can set the cookie triggering via javascript
   the consent…
 *  Plugin Author [christophrado](https://wordpress.org/support/users/christophrado/)
 * (@christophrado)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/javascript-hook-avoiding-relad-the-page/#post-15253173)
 * Ah, I see. I don’t know if it’s legal (based on your requirements and privacy
   laws), but you could basically do this:
 * Add the base code (with gtag ‘ad_storage’: ‘denied’) into the “Essential” category,
   and add the gtag with “‘ad_storage’: ‘granted'” code bit into the “Marketing”
   category. That way, the base code will always be output, and the ad consent will
   be output once the Marketing category has been accepted.
 * The additional “granted” code will not be output without a page reload though.
   Without page reload, additional code will only be output on the next page load(
   be it the same or a different page that the user navigates to).

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Javascript hook avoiding relad the page’ is closed to new replies.

 * ![](https://ps.w.org/cookie-notice-consent/assets/icon-256x256.png?rev=2471736)
 * [Cookie Notice & Consent](https://wordpress.org/plugins/cookie-notice-consent/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cookie-notice-consent/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cookie-notice-consent/)
 * [Active Topics](https://wordpress.org/support/plugin/cookie-notice-consent/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cookie-notice-consent/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cookie-notice-consent/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [christophrado](https://wordpress.org/support/users/christophrado/)
 * Last activity: [4 years, 4 months ago](https://wordpress.org/support/topic/javascript-hook-avoiding-relad-the-page/#post-15253173)
 * Status: not a support question