Naj_1 0 Newbie Poster

Hi everyone,

I am currently building a wordpress site related to the photo which will be used to carry out many social projects. It's been months that I block on one subject, I am looking desperately for a person who would have the kindness and the skills to bring me help.

My problem: RGPD compliance third-party cookies

The situation is as follows, I have installed Google Tag Manager, it is functional, I am trying to configure it to "block" all third-party cookies on my site, while the user gives his consent to use these third-party cookies. When he clicks on 'accept' (cookie banner), third-party cookies are installed and as long as the user does not purge their browser cache, third-party cookies are loaded with each page load. *
The function of the google tag manager code would be to analyze the "viewed_cookie_policy" cookie, if so, the user to give his agreement and google tag manager can load third-party cookies. If the "viewed_cookie_policy" cookie does not exist, then the user has not given their consent and third-party cookies remain blocked.

More Technic :

wordpress: 5.5 / php: 7.4.8 / serveur: apache / mysql: 5. 7. 28 / shared hosting 1&1

Plugin cookies : GDPR Cookie Consent Plugin (CCPA Ready)
By WebToffee

i have try this setup in google manager :

Variable = Type : proprietary cookies = name = viewed_cookie_policy (viewed_cookie_policy with value "yes" = is the name of the cookies are created when people clic " Consent" on the cookies banner)

Trigger : page view = some pages viewed = viewed_cookie_policy | contains | yes

TAG : (i have try with only one third cookies for try, is for this i have put only one link, third cookie " stripe " )

this setup work but the script " js.stripe.com/v3/ " is loading before " click consent " for leave the script i have install the plugin : Asset CleanUp: Page Speed Booster
By Gabriel Livan

With this plugin i ask him to block the third cookie " js.stripe.com/v3/ " everywhere on my website, this action work.

At this step, when i clean all my cache, i go to my website, the " js.stripe.com/v3/ " don't load (It's OK) and i click " consent " on banner cookies, the page reload alone and the cookies third party " js.stripe.com/v3/ " load (until here all it's ok) the things is when i try to use the plugin " Give " (this plugin use js.stripe.com/v3/) when i make test for donation and i'm redirect " https://checkout.stripe.com/pay/ " the page not loading and are full white ... When i desactivate the option for don't load js.stripe.com/v3/ in " Asset CleanUp plugin " and i try again it's work but is not good because with this configuration, the third cookie " js.stripe.com/v3/ " are load when people come on my website and js.stripe.com/v3/ is loading before people clic " Consent " on banner cookies ... Madness circle ... I have hard hard try since long time but i don't find the solution ....

Thank you for your help I can give you more information if you need (for example the url of my website) in a private message.

Dani AI

Generated

— short practical summary and concrete options to unblock Stripe without breaking Give:

Blocking https://js.stripe.com/v3/ until consent is fine, but the Give front-end usually expects the Stripe library to exist when it initializes. Asset CleanUp can prevent the external script tag from loading but it won't stop inline initialization code or cached HTML from running; that mismatch (library missing when plugin JS runs) is the usual cause of a white/blank checkout page.

Server-side conditional enqueue (recommended)
Place a small function in a child-theme functions.php or a tiny mu-plugin so Stripe is only enqueued when the consent cookie is present. That avoids race conditions and works with plugins that initialize on page load.

add_action('wp_enqueue_scripts','maybe_enqueue_stripe',20);
function maybe_enqueue_stripe(){
  if ( isset($_COOKIE['viewed_cookie_policy']) && $_COOKIE['viewed_cookie_policy'] === 'yes' ) {
    wp_enqueue_script('stripe-js','https://js.stripe.com/v3/',[],null,true);
  }
}

GTM / client-side dynamic loader (alternative)
If staying with GTM, inject stripe.js after consent and then trigger an event so Give can reinitialize. Example custom HTML tag:

(function(){
  var s = document.createElement('script');
  s.src = 'https://js.stripe.com/v3/';
  s.async = true;
  s.onload = function(){ window.dispatchEvent(new Event('stripe:loaded')); };
  document.head.appendChild(s);
})();

A listener should call the Give plugin's public init or reattach handlers (check Give docs for the exact method). If the plugin exposes no init hook, reloading the page after consent is the simpler fallback.

Debug checklist and cautions

  • Search page source for inline scripts that reference Stripe; those must be gated or re-run after loading the library.
  • Make caches respect the consent cookie (add Vary: Cookie or exclude donation pages) — otherwise cached HTML without Stripe will be served.
  • Test in a private window, watch Network/Console for window.Stripe and errors.
  • Consider treating payment scripts as "necessary" on donation/checkout pages (legal/consent implications vary by jurisdiction; consult guidance if unsure).

This approach keeps consent gating while ensuring the payment flow initializes only when the Stripe library is actually available.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.