Jump to content

PrivacyWire - Cookie Management & async external asset loading


joshua

Recommended Posts

2 hours ago, fruid said:

The cookie domain of these 13 cookies in the console is .vimeo.com, so are they out of scope? Maybe it's just my lack of understanding… 

You need to avoid loading the iframe just try:

<iframe 
src=""
data-src="https://player.vimeo.com/video/<?=$page->vimeoID;?>?color=5a90ff&portrait=0" 
data-category="marketing"
style="position:absolute;top:0;left:0;width:100%;height:100%;" 
frameborder="0" 
allow="autoplay; fullscreen" 
allowfullscreen>
</iframe>

This will block the whole iframe to be loaded until the user agree to us "marketing" cookies. With a little bit of css you can hide the empty iframes:

iframe[src=""]{display:none};

 

  • Like 1
Link to comment
Share on other sites

21 hours ago, DV-JF said:

<iframe 
src=""
data-src="https://player.vimeo.com/video/<?=$page->vimeoID;?>?color=5a90ff&portrait=0" 
data-category="marketing"
style="position:absolute;top:0;left:0;width:100%;height:100%;" 
frameborder="0" 
allow="autoplay; fullscreen" 
allowfullscreen>
</iframe>

 

I did this. If I leave the src tag empty, nothing is loaded. If I accept the marketing cookies, nothing is loaded either 😞
I'm on local BTW, not sure if that's relevant

Link to comment
Share on other sites

Hi. Is it possible to make it like a window or modal centered in the middle of the page and the background overlayed with a half transparent color?
I tried to customize it via CSS but didn’t manage it. Maybe there is an easier solution for this?

Link to comment
Share on other sites

  • 2 weeks later...
On 3/18/2021 at 1:57 PM, fruid said:

I did this. If I leave the src tag empty, nothing is loaded. If I accept the marketing cookies, nothing is loaded either 😞
I'm on local BTW, not sure if that's relevant

You can ommit the src attribute also. In my test case it works that way.
I use it a lot in combination with vimeo video and used the implementation as in this video

Link to comment
Share on other sites

On 3/23/2021 at 10:28 AM, Matze said:

Hi. Is it possible to make it like a window or modal centered in the middle of the page and the background overlayed with a half transparent color?
I tried to customize it via CSS but didn’t manage it. Maybe there is an easier solution for this?

You mean something like the screenshot attached?

That's possible with some CSS (this is just an example, how one could do this)


    .show-banner > .privacywire-page-wrapper,
    .show-options > .privacywire-page-wrapper,
    .show-message > .privacywire-page-wrapper {
        position: fixed;
        left: 0;
        top: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(5px);
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .privacywire {
        display: none;
    }

    .show-banner .privacywire.privacywire-banner,
    .show-options .privacywire.privacywire-options,
    .show-message .privacywire.privacywire-message {
        display: block;
        position: relative;
        left: auto;
        right: auto;
        bottom: auto;
        max-width: 450px;
    }

 

Bildschirmfoto 2021-04-05 um 14.58.19.png

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

I started having trouble with <script type=text/plain" data-type="text/javascript" data-category="external_media" class="require-consent">

I get a JS error and the element isn't shown (any more?) on consent. Anyone else sees this too? Or did I use this in an unintended way? (Example)

 

Link to comment
Share on other sites

8 minutes ago, ceberlin said:

<script type=text/plain" data-type="text/javascript" data-category="external_media" class="require-consent">

In this example the starting quote at the type attribute is missing:

<script type="text/plain" data-type="text/javascript" data-category="external_media" class="require-consent">...</script>

In your example:

grafik.thumb.png.46242ea432b39cd9e48c40b9d1d4e4f1.png

 

Does it work with the quotation mark?

  • Like 1
Link to comment
Share on other sites

Thanks for noticing! I fixed the typo in the git repo, should be updated in the PW module repo soon.

Hm, I'm looking into this problem. Which version of PrivacyWire are you using?

  • Like 2
Link to comment
Share on other sites

Thank you @joshua for this great module!

Everything works perfectly. Only I can't get IE11 support to work.
I'm on ProcessWire 3.0.165 with PrivacyWire 1.0.4.
JS console says:

Quote

Object doesn't support property or method 'from'
PrivacyWire_legacy.js (1,10449)

Yes I know I should drop IE11 support... but this is more a legal issue than a functional or cosmetic one.

Edited by webaff
added system info
Link to comment
Share on other sites

  • 4 weeks later...

Hey @joshua,

I'm using your module in a "project master copy" of PW. Every time I start a new project I mirror this master copy.

Most of the time I don't need a consent banner - so a deinstall it. The disadvantage of this procedure is that if I need the banner later or the customer wants to add a banner, I have to make all the settings again after installing it.

Therefore it would be nice to have an option to disable the module. What do you think about this improvement?

Greets Jens alias DV-JF

  • Like 1
Link to comment
Share on other sites

Hi Jens,

sounds like an good workflow and also a nice improvement for the PrivacyWire module config.
I'll add it as soon as I find the time.

Best,
Joshua

  • Like 2
Link to comment
Share on other sites

  • 1 month later...

I installed the module and the privacywire code (js and css) appears in my sourcecode (in the head) but the cookie toolbar insn't shown up.

<style>.privacywire{position:fixed;bottom:-250%;left:0;right:0;box-shadow:0 -1px 3px rgba(0,0,0,.3);opacity:0;background:#fff;z-index:1;padding:1rem;transition:bottom .3s ease-in,opacity .3s ease}.show-banner .privacywire-banner,.show-message .privacywire-message,.show-options .privacywire-options{bottom:0;opacity:1}.privacywire-header{font-weight:700}.privacywire-ask-consent-blueprint,.privacywire button[hidden],[data-ask-consent-rendered="1"]{display:none}</style>
<script>var PrivacyWireSettings={"version":1,"dnt":"0","customFunction":"","messageTimeout":1500,"consentByClass":"1","cookieGroups":{"necessary":"Necessary","functional":"Functional","statistics":"Statistik","marketing":"Marketing","external_media":"External Media"}};</script><script type='module' src='.../site/modules/PrivacyWire/js/PrivacyWire.js'></script><script nomodule type='text/javascript' src='/.../site/modules/PrivacyWire/js/ie_polyfill.js'></script><script nomodule type='text/javascript' src='.../site/modules/PrivacyWire/js/PrivacyWire_legacy.js'></script>

Is there somethings missing or do i make a mistake?
Thanks!

Link to comment
Share on other sites

Is your ProcessWire instance installed in the root web directory or somewhere else?

The only noticible change I find in your code examle is the directory within the script tag:

<script nomodule type='text/javascript' src='.../site/modules/PrivacyWire/js/PrivacyWire_legacy.js'>

Usually the src attribute starts directly with '/site/' instead of '.../site/'

<style>.privacywire{position:fixed;bottom:-250%;left:0;right:0;box-shadow:0 -1px 3px rgba(0,0,0,.3);opacity:0;background:#fff;z-index:1;padding:1rem;transition:bottom .3s ease-in,opacity .3s ease}.show-banner .privacywire-banner,.show-message .privacywire-message,.show-options .privacywire-options{bottom:0;opacity:1}.privacywire-header{font-weight:700}.privacywire-ask-consent-blueprint,.privacywire button[hidden],[data-ask-consent-rendered="1"]{display:none}</style>
<script>var PrivacyWireSettings={"version":1,"dnt":"0","customFunction":"","messageTimeout":1500,"consentByClass":"1","cookieGroups":{"necessary":"Necessary","functional":"Functional","statistics":"Statistics","marketing":"Marketing","external_media":"External Media"}};</script>
<script type='module' src='/site/modules/Privacywire/js/PrivacyWire.js'></script>
<script nomodule type='text/javascript' src='/site/modules/Privacywire/js/ie_polyfill.js'></script>
<script nomodule type='text/javascript' src='/site/modules/Privacywire/js/PrivacyWire_legacy.js'></script>

 

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
On 6/30/2021 at 8:51 AM, joshua said:
<style>.privacywire{position:fixed;bottom:-250%;left:0;right:0;box-shadow:0 -1px 3px rgba(0,0,0,.3);opacity:0;background:#fff;z-index:1;padding:1rem;transition:bottom .3s ease-in,opacity .3s ease}.show-banner .privacywire-banner,.show-message .privacywire-message,.show-options .privacywire-options{bottom:0;opacity:1}.privacywire-header{font-weight:700}.privacywire-ask-consent-blueprint,.privacywire button[hidden],[data-ask-consent-rendered="1"]{display:none}</style>
<script>var PrivacyWireSettings={"version":1,"dnt":"0","customFunction":"","messageTimeout":1500,"consentByClass":"1","cookieGroups":{"necessary":"Necessary","functional":"Functional","statistics":"Statistics","marketing":"Marketing","external_media":"External Media"}};</script>
<script type='module' src='/site/modules/Privacywire/js/PrivacyWire.js'></script>
<script nomodule type='text/javascript' src='/site/modules/Privacywire/js/ie_polyfill.js'></script>
<script nomodule type='text/javascript' src='/site/modules/Privacywire/js/PrivacyWire_legacy.js'></script>

 

Thanks for your answer!

I changed the .../site path just for the forum post.

After restarting the browser (new session) the privace wire toolbar is shown up!
 

 

  • Like 1
Link to comment
Share on other sites

  • 5 weeks later...

I have the following situation: in my initial html markup there is a PrivacyWire-ShowOptions link that gets initiated by the PrivacyWire module on content loaded.
Every thing works fine, as expected. 
After that, I update a part of the html markup (with the PrivacyWire-ShowOptions link included) via AJAX. The initial link is gone now, and the new link is not bound to the PrivacyWire event.
How can I bind it to the PrivacyWire event to show the options banner? A line of code or a keyword hint would be of great help. 🙂

 

Link to comment
Share on other sites

2 hours ago, horst said:

A line of code or a keyword hint would be of great help.

I just added a small function for this usecase in v1.0.7. You can trigger this "re-initiating" by calling

window.PrivacyWire.reHandleExternalButtons()

Updated / Added code: https://github.com/webworkerJoshua/privacywire/blob/1.0.7/src/js/PrivacyWire.js#L146-L149

  • Thanks 1
Link to comment
Share on other sites

41 minutes ago, joshua said:

I just added a small function for this usecase in v1.0.7. You can trigger this "re-initiating" by calling

window.PrivacyWire.reHandleExternalButtons()

Hey, many many thanks! Works fine!

Your support is extraordinary! 🙂 🙏 👍

  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...

Hi, I've got a site that uses multi-language URLs based on a query-param, ie. https://example.com/some/page?lang=de.
The site exists of a Vue.js app on top of a very basic HTML skeleton generated by PW, and we don't use the LanguageSupportPageNames module at all (so no example.com/de & example.com/en ).

In order to set the initial skeleton HTML (such as page title etc), which gets rendered before the Vue app has booted, I set my $user->language based on the $input->get('lang') value. After the Vue app has booted, it takes over control and loads the remaining data in the appropriate language through a multilingual API endpoint.

Next to the Vue app, we also use PrivacyWire.

However, due to the way PrivacyWire has been built, it looks at the $users language BEFORE any of this takes place (in its ready() function).
As a result, I can't get the correct language content inside the PrivacyWire popups, it always shows the default language content instead.

So probably I need to hook into the getPrivacyWireConfigObject method, and overrule the PrivacyWire::lang variable with the language that I get from my $input->get('lang')?
Or would there be another, easier approach?

Any pointers would be most welcome! Thanks.

Link to comment
Share on other sites

3 hours ago, eelkenet said:

However, due to the way PrivacyWire has been built, it looks at the $users language BEFORE any of this takes place (in its ready() function).

That's correct, currently PrivacyWire loads itself in the module ready() method.

I played around with some settings to load PrivacyWire later. You can find the feature in this branch:
https://github.com/webworkerJoshua/privacywire/tree/feature-initiate-privacywire-laster
In this version PrivacyWire initiates itself before Page::render:

$this->addHookBefore('Page::render', $this, 'initiatePrivacyWire');

Could you try this version and confirm, that it's working the way you wanted / expected? After that I will do some more testing before merging into the main branch just to be sure that there are no side effects 😉

Thanks!
 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Hi @joshua, that works - sort of. When setting the user language inside a template we still only get the default language, as your hook gets called earlier. 

However, what does work is hooking into the same Page::render method with a lower priority number, so our code gets an earlier execution. Great!

In ready.php we now have:

<?php

namespace ProcessWire;

// Hook into Page::render, just before PrivacyWire's hook 
// Which uses the default priority of 100
wire()->addHookBefore('Page::render', function (HookEvent $evt) {

  // Only apply to front-end pages
  $page = $evt->object;
  if (
    $page->template == 'admin' || // exclude admin pages
    $page->template == 'form-builder' // exclude from form-builder iframe
  ) {
    return;
  }

  $user = wire()->user;
  $languages = wire()->languages;
  
  // Get and sanitize the ?lang= get param
  $lang = strtolower(wire()->input->get("lang", "text"));

  // Set appropriate language
  if ($lang === "en") {
    $user->language = $languages->get("default");
  } else {
    $user->language = $languages->get("de");
  }
}, ['priority' => 99]);

 

 

  • Like 2
Link to comment
Share on other sites

1 hour ago, eelkenet said:

However, what does work is hooking into the same Page::render method with a lower priority number, so our code gets an earlier execution. Great!

That's great! Thanks for the feedback. It is even easier now in v1.0.9 as I reduced the hook priority, so every "usual" hook written inside a template should work, too.

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Similar Content

    • By MarkE
      This fieldtype and inputfield bundle was built for storing measurement values within a field, rendering them in a variety of formats and converting them to other units or otherwise modifying them via the API.
      The API consists of a number of predefined functions, some of which include...
      render() for rendering the measurement object, valueAs() for converting the value to another unit value, convertTo() for converting the whole measurement object to different units, and add() and subtract() for creating a new measurement object from the sum or difference between two other objects. In the admin the inputfield includes a checkbox (which can be optionally disabled) for converting values on page save. For an example if a value was typed in as centimeters, the unit was changed to metres, and the page saved with this checkbox selected, said value would be automatically converted so that e.g. 170 cm becomes 1.7 m.
      A simple length field using Fieldtype Measurement and Inputfield Measurement.
      Combination units (e.g. feet and inches) are also supported.
      Please note that this module is 'proof of concept' at the moment - there are limited units available and quite a lot of code tidying to do. More units will be added shortly.
      See the GitHub at https://github.com/MetaTunes/FieldtypeMeasurement for full details and updates.
    • By tcnet
      File Manager for ProcessWire is a module to manager files and folders from the CMS backend. It supports creating, deleting, renaming, packing, unpacking, uploading, downloading and editing of files and folders. The integrated code editor ACE supports highlighting of all common programming languages.
      https://github.com/techcnet/ProcessFileManager

      Warning
      This module is probably the most powerful module. You might destroy your processwire installation if you don't exactly know what you doing. Be careful and use it at your own risk!
      ACE code editor
      This module uses ACE code editor available from: https://github.com/ajaxorg/ace

      Dragscroll
      This module uses the JavaScript dragscroll available from: http://github.com/asvd/dragscroll. Dragscroll adds the ability to drag the table horizontally with the mouse pointer.
      PHP File Manager
      This module uses a modified version of PHP File Manager available from: https://github.com/alexantr/filemanager
       
    • By tcnet
      This module implements the website live chat service from tawk.to. Actually the module doesn't have to do much. It just need to inserted a few lines of JavaScript just before the closing body tag </body> on each side. However, the module offers additional options to display the widget only on certain pages.
      Create an account
      Visit https://www.tawk.to and create an account. It's free! At some point you will reach a page where you can copy the required JavaScript-code.

      Open the module settings and paste the JavaScript-code into the field as shown below. Click "Submit" and that's all.

      Open the module settings
      The settings for this module are located int the menu Modules=>Configure=>LiveChatTawkTo.

       
    • By tcnet
      Session Viewer is a module for ProcessWire to list session files and display session data. This module is helpful to display the session data of a specific session or to kick out a logged in user by simply delete his session file. After installation the module is available in the Setup menu.

      The following conditions must be met for the module to work properly:
      Session files
      Session data must be stored in session files, which is the default way in ProcessWire. Sessions stored in the database are not supported by this module. The path to the directory where the session files are stored must be declared in the ProcessWire configuration which is by default: site/assets/sessions.
      Serialize handler
      In order to transform session data easier back to a PHP array, the session data is stored serialized. PHP offers a way to declare a custom serialize handler. This module supports only the default serialize handlers: php, php_binary and php_serialize. WDDX was dropped in PHP 7.4.0 and is therefore not supported by this module as well as any other custom serialize handler. Which serialize handler is actually used you can find out in the module configuration which is available under Modules=>Configure=>SessionViewer.

      Session data
      The session data can be displayed in two different ways. PHP's default output for arrays print_r() or by default for this module nice_r() offered on github: https://github.com/uuf6429/nice_r. There is a setting in the module configuration if someone prefers print_r(). Apart from the better handling and overview of the folded session data the output of nice_r() looks indeed nicer.

      Links
      ProcessWire module directory
      github.com
    • By Robin S
      Repeater Easy Sort
      Adds a compact "easy-sort" mode to Repeater and Repeater Matrix, making those fields easier to sort when there are a large number of items.
      The module also enhances Repeater Matrix by allowing a colour to be set for each matrix type. This colour is used in the item headers and in the "add new" links, to help visually distinguish different matrix types in the inputfield.
      Screencasts
      A Repeater field

      A Repeater Matrix field with custom header colours

      Easy-sort mode
      Each Repeater/Matrix item gets an double-arrow icon in the item header. Click this icon to enter easy-sort mode.
      While in easy-sort mode:
      The items will reduce in width so that more items can be shown on the screen at once. The minimum width is configurable in the field settings. Any items that were in an open state are collapsed, but when you exit easy-sort mode the previously open items will be reopened. You can drag an item left/right/up/down to sort it within the items. The item that you clicked the icon for is shown with a black background. This makes it easier to find the item you want to move in easy-sort mode. You can click an item header to open the item. An "Exit easy-sort mode" button appears at the bottom of the inputfield. Configuration
      In the field settings for Repeater and Repeater Matrix fields you can define a minimum width in pixels for items in easy-sort mode. While in easy-sort mode the items will be sized to neatly fill the available width on any screen size but will never be narrower than the width you set here.
      In the field settings for Repeater Matrix you can define a custom header colour for each matrix type using an HTML "color" type input. The default colour for this type of input is black, so when black is selected in the input it means that no custom colour will be applied to the header.
      Exclusions
      The easy-sort mode is only possible on Repeater/Matrix fields that do not use the "item depth" option.
       
      https://github.com/Toutouwai/RepeaterEasySort
      https://processwire.com/modules/repeater-easy-sort/
×
×
  • Create New...