• Resolved agarimo

    (@agarimo)


    Hi there, and thanks in advance for your help!
    I´m working on a WordPress site wich should embed iframes from in-house tools, hosted in other domain which loads their own cookies. I´m currently passing parameters with iframe url (as name or phone numer) and we need to pass as parameter the user cookies aceptance level (I mean: if all cookies are accepted or just the functional ones) so the iframe responds accordingly.
    I´m strugling trying to find an existing or create a new shortcode to concatenate to the url as parameter value so the iframe destination knows if it have to load analytics cookies or doesn´t.
    Somehow like this:
    <iframe src=”iframeurl?name=[urlparam param=”customername” default=”notfound”/]&cookies=[here goes the shortcode]”/iframe>

    Is this possible? I´ve tryed with several code snippets but cannot find how to create a shortcode that returns the cookies aceptance level.

    Thanks a lot!

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Jarno Vos

    (@jarnovos)

    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

    Thread Starter agarimo

    (@agarimo)

    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!!

    Plugin Contributor Rogier Lankhorst

    (@rogierlankhorst)

    @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' );
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Shortcode to retrieve aceptance’ is closed to new replies.