Hi @agarimo,
Due to security reasons, it is not possible to load or influence third-party cookies from your domain, outside of the iFrame.
Aside from this, to load an iFrame based on the user consent type you could:
1) Add placeholders for iFrames
In the Script Center, you will find an editor for iFrames. Here you can add the URLs to block your iFrames.
Please refer to our guide here: https://complianz.io/placeholders-for-iframes
2) Check the cookies placed by Complianz in Javascript
You can check the cookies placed by Complianz for the current consent status, please refer to our guide here: https://complianz.io/developers-guide-for-third-party-integrations/
3) Wrapping the content using the consent area shortcode
[cmplz-consent-area text="Enable this content by clicking this link"]
/* add your snippet or iFrame that needs to be blocked before consent */
[/cmplz-consent-area]
For a complete guide on how to implement the consent area including CSS styling, please refer to https://complianz.io/wrapping-content-in-consent-shortcodes/
Hope this helps,
Jarno
Thanks a lot for your help, Jarnovos!
But maybe I haven´t explained properly, please apologize.
I do not need to influence on cookies loaded by the iframe, at least not directly.
I just need to retrieve the user aceptance value in order to concatenate to the iframe url. Of course, on the other iframe side, they will develop a logic in order to load or not load G.analytics scripts accordlingy to the value of parameter on the url.
So, basically, my question is: is there an existing shortcode that allows me to retrieve the user level consent? Something like [cookies-allowance] that provides a value to me to concatenate to the iframe url?
Thanks a lot!!
@agarimo,
With a shortcode this wouldn’t get updated when the user accepts, only after a reload, and even then, this would conflict with cached configurations.
What I would do, is add a little jquery script which hooks into the consent hook from the banner, then reloads the iframe with the new cookie appended. Is this what you’re looking for?
function cmplz_maybe_add_variable() {
?>
<script>
jQuery(document).ready(function ($) {
//this event fires on marketing consent
document.addEventListener('cmplzEnableScriptsMarketing', function (e){
$('iframe').each(function (i, obj) {
//skip blocked frames
if ( $(this).hasClass('cmplz-iframe') ) return;
var src = $(this).attr('src');
src = src+'&cookie=marketing';
$(this).attr('src', src);
}
});
});
</script>
<?php
}
add_action( 'wp_footer', 'cmplz_maybe_add_variable' );