Jump to content

PrivacyWire - Cookie Management & async external asset loading


joshua

Recommended Posts

Hey @joshua,

I'm wondering if it would be possible to load a poster image in a <video> tag only when the user accepts the category: In my example I'm loading an external video and it would be nice to do something like this:

<video src="" data-src="http://example.com/video.mp4" data-category="external-media" data-poster="http://example.com/video_preview_image.jpg"></video>

Any ideas or plans?

Greets Jens alias DV_JF

Link to comment
Share on other sites

  • 1 month later...

Hi @joshua
Can you let me know how I exclude Piwik/Matomo tracking from "only essential cookies"?
 

<script type="text/javascript">
  var _paq = _paq || [];
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u=(("https:" == document.location.protocol) ? "https" : "http") + "://www.URL.ch/piwik/";
    _paq.push(['setTrackerUrl', u+'piwik.php']);
    _paq.push(['setSiteId', 1]);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript';
    g.defer=true; g.async=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
  })();
</script>
<noscript>
<p><img src="http://www.URL.ch/piwik/piwik.php?idsite=1" style="border:0;" alt="" /></p>
</noscript>

 

Link to comment
Share on other sites

@ngrmm
Thanks for your super fast reply.
My code looks like this now and is placed just before </body>

<script type="text/javascript" data-type="text/javascript" data-category="statistics" class="require-consent">/* PrivcyWire */
/* <script type="text/javascript"> */
  var _paq = _paq || [];
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u=(("https:" == document.location.protocol) ? "https" : "http") + "://www.URL.ch/piwik/";
    _paq.push(['setTrackerUrl', u+'piwik.php']);
    _paq.push(['setSiteId', 1]);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript';
    g.defer=true; g.async=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
  })();
</script>

General Settings in PrivacyWire are only including the default "All Cookies" and "Necessary Cookies" and Piwik is still tracking after empty cache and click on "Necessary Cookies". Is data-category="statistics" included in "necessary"? I also tried data-category="necessary" but still tracking ... any idea?
Website is this one

Bildschirmfoto 2022-12-28 um 17.25.55.jpg

Link to comment
Share on other sites

Thanks for the answers. My first line Piwik/Matomo now looks like this:

<script data-category="statistics" class="require-consent">

I also tried out:

<script data-category="necessary" class="require-consent">

as I only use "all Cookies" and "Necessary Cookies" from the module and no extra Cookie group for Statistics.

Both possibilities still track the Website after empty Cache and clicking "Necessary Cookies".

Any more Ideas to get that fixed?

Link to comment
Share on other sites

Just now, Web-ID said:

Thanks for the answers. My first line Piwik/Matomo now looks like this:

<script data-category="statistics" class="require-consent">

I also tried out:

<script data-category="necessary" class="require-consent">

as I only use "all Cookies" and "Necessary Cookies" from the module and no extra Cookie group for Statistics.

Both possibilities still track the Website after empty Cache and clicking "Necessary Cookies".

Any more Ideas to get that fixed?

you need to have the cookie group Statistics on the list.

Link to comment
Share on other sites

I added cookie group statistics. Still tracking on Piwik/Matomo if chosen like on the pic: no check "statistics" and click on "Save Preferences".
Still wondering what is wrong in my code ...

Also wondering what is the difference between: "Accept all" and "Accept necessary cookies only". Does "Accept necessary cookies only" not deleete all other cookies than the ones needed from PW? Which would mean statistics, marketing etc?
Thanks a lot for your support.

statistics.jpg

Link to comment
Share on other sites

5 minutes ago, Web-ID said:

Also wondering what is the difference between: "Accept all" and "Accept necessary cookies only". Does "Accept necessary cookies only" not deleete all other cookies than the ones needed from PW? Which would mean statistics, marketing etc?
Thanks a lot for your support.

"Accept all" means YES to all groups
"Accept necessary cookies only" means YES only to necessary cookie (NO to statistics, external …)

Try it like in the docs:

<script type="text/plain" data-type="text/javascript" data-category="statistics" data-src="/path/to/your/statistic/script.js"></script>

Do you work local or on a webserver?

Link to comment
Share on other sites

Working! ?
with this:

<script type="text/plain" data-type="text/javascript" data-category="statistics">
/* piwik/matomo code */
</script>

same if js is in an external file:

<script type="text/plain" data-type="text/javascript" data-category="statistics" data-src="<?= $config->urls->templates ?>scripts/piwik.js"></script> 

And the best: I can reduce to "Accept all Cookies" and "Essential Cookies only" and it works!
Same with the "Statistics" included as an Cookie group. All variants working!
@ngrmmcan I contribute something for your help?
(I work on a web server)

  • Like 1
Link to comment
Share on other sites

1 minute ago, Web-ID said:

Working! ?
with this:

<script type="text/plain" data-type="text/javascript" data-category="statistics">
/* piwik/matomo code */
</script>

same if js is in an external file:

<script type="text/plain" data-type="text/javascript" data-category="statistics" data-src="<?= $config->urls->templates ?>scripts/piwik.js"></script> 

And the best: I can reduce to "Accept all Cookies" and "Essential Cookies only" and it works!
Same with the "Statistics" included as an Cookie group. All variants working!
@ngrmmcan I contribute something for your help?

no thx ? but maybe to @joshua the creator of the module.
 

Link to comment
Share on other sites

  • 2 weeks later...

Just a thought/idea but...

Wouldn't it be a nice addition to make the cookie banner only show up when more than the "necessary cookies" group is set in the settings?

At least in Germany (which is super strict in terms of cookies and such) you don't have to accept those but only additional tracking cookies or whatever 3rd party-cookies.

Do I miss a thought here? Or would this be a great addition for all?

  • Like 1
Link to comment
Share on other sites

5 hours ago, wbmnfktr said:

Just a thought/idea but...

Wouldn't it be a nice addition to make the cookie banner only show up when more than the "necessary cookies" group is set in the settings?

At least in Germany (which is super strict in terms of cookies and such) you don't have to accept those but only additional tracking cookies or whatever 3rd party-cookies.

Do I miss a thought here? Or would this be a great addition for all?

Good idea, but maybe it's better to have this optional. I explained this so many times to clients but some of them still would like to have something like an explainer popup.

But another topic is the obligation to protocol clicks/sessions (GDPR) for sites which have more than necessary cookies. I messaged @joshua a while ago, but he had no time back then. Maybe someone else could come up with a solution? I don't have the skill to do that, but would be happy to sponsor the work.

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

@joshua I have read the documentation. Sorry, no banner is displayed for me after I confirmed it once days ago. Unfortunately, in none of three browsers (macOS).

At Klaro there is a possibility to keep the dialog visible via a code https://example.com#klaro-testing. How do I get to see it on PrivacyWire?

Functionality:
What do I do after installation, how do I add these following Processwire modules / functions:

OpenStreetMap
(FieldtypeLeafletMapMarker, InputfieldLeafletMapMarker, MarkupLeafletMap)

Video embed for YouTube (and Vimeo)
(TextformatterVideoEmbed)

In the documentation I read:
"When you want to load specific scripts ( like Google Analytics, Google Maps, ...) only after the user's content … add 'data-category="statistics"'"

The module for OpenStreetMap is integrated like this:
   <?php $map = wire('modules')->get('MarkupLeafletMap'); ?>
   <?php echo $map->getLeafletMapHeaderLines(); ?>
I can't add anything, if I haven't overseen something?

In the TextformatterVideoEmbed options I have this GDPR option:
[ ] GDPR: Use the no-cookie / do-not-track version of video URLs
but no possibility to extend the module code as shown in the documentation. I am probably completely wrong with my assumption that this is the way to connect things to PrivacyWire?

Sorry if I oversaw something, the more I read the more it confuses me. Maybe it will work sometime, to enable installed things like TextformatterVideoEmbed in PrivacyWire, and done ?
Thanks for the module, I'm just struggling a bit with the functionality.

Link to comment
Share on other sites

  • 1 month later...

It would be a very useful feature. Setting up PrivacyWire from ground up is a bit of work and not all my sites need it. It would be easier to be able to switch it on/off depending on the clients needs.

4 hours ago, DV-JF said:

@StefanowitschAt the moment there's no option to do that. I've asked somewhere earlier in this thread about it and would like to have this function, too. ?

Link to comment
Share on other sites

  • 2 months later...

Hi 

@joshua

Thank you for what looks to be a great module and excellent support. I'm hoping to get some pointers from you as PrivacyWire isn't working as expected on my website somehow.

I'm on PrivacyWire v1.1.2. and checked the 'active' checkbox in config screen.

The module is loading fine, and I'm getting the banner allright - but no element is stopped from loading at all! On my test page , no matter what i try, i still get to read "This script only runs after giving consent to functional cookies" in my console! But I haven't given consent.

All assets seem to be loading fine:

<head>
<style>.privacywire{background:#fff;bottom:-250%;box-shadow:0 -1px 3px rgba(0,0,0,.3);left:0;opacity:0;padding:1rem;position:fixed;right:0;transition:bottom .3s ease-in,opacity .3s ease;z-index:1}.show-banner .privacywire-banner,.show-message .privacywire-message,.show-options .privacywire-options{bottom:0;opacity:1}.privacywire-header{font-weight:700}.privacywire button[hidden],.privacywire-ask-consent-blueprint,[data-ask-consent-rendered="1"]{display:none}</style>
<script>var PrivacyWireSettings={"version":2,"dnt":"1","bots":"1","customFunction":"","messageTimeout":2500,"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>	

 

On the page in the <body> i've put the example script


<script  data-type="text/javascript" data-category="functional" class="require-consent">console.log("This script only runs after giving consent to functional cookies");</script>

and in the console the message shows.

Then: when i give consent- it shows up again in the console!

I'm lost on what to do and how to figure out what i could be doing wrong...

Any help would be much appreciated!

 

Link to comment
Share on other sites

On 6/3/2023 at 8:26 AM, Ellyot_Chase said:

On the page in the <body> i've put the example script


<script  data-type="text/javascript" data-category="functional" class="require-consent">console.log("This script only runs after giving consent to functional cookies");</script>

and in the console the message shows.

Then: when i give consent- it shows up again in the console!

 

Hi @Ellyot_Chase,

in the above example you posted there is no type defined on the script element.
See the original example here:

<script type="text/plain" data-type="text/javascript" data-category="functional" class="require-consent">console.log("This script only runs after giving consent to functional cookies");</script>

Without the `type="text/plain"` the browser immediately executes the script, PrivacyWire has no chance to stop this behaviour.
When you add the type, the script should only be loaded after the user has given consent.

 

  • Like 1
Link to comment
Share on other sites

I don't know if this was discussed already before... so in case you need to check if PrivacyWire is enabled to show/hide things, like a custom cookie-settings button or link.

This is how you check if PrivacyWire is enabled:

// needs $config->useFunctionsAPI = true;
$privacyWireModule = modules()->get('PrivacyWire');

// check if PrivacyWire is active
$privacyWireIsActive = $privacyWireModule->is_Active;

// down in your template
if($privacyWireIsActive) {
// do whatever you need
}

 

  • Like 1
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
×
×
  • Create New...