Quantcast
Channel: Matomo forums - Latest topics
Viewing all articles
Browse latest Browse all 13999

Colorcoding the current Opt-Out-Status in iFrame

$
0
0

@Lukas wrote:

Inspired by this and this tweet.

Sometimes you may want to make it more obvious if a user is currently opted-in by colorcoding the Opt-Out-iFrame.

This is simply possible thanks to the great https://plugins.matomo.org/customoptout plugin.

Simply enter the following JS code into the corresponding text box and use the custom iframe. (You need to enable custom JS in the plugin settings first)

var trackVisits = document.getElementById("trackVisits");

function setColor() {
    if (trackVisits.checked) {
        document.body.style.backgroundColor = "red";
    } else {
        document.body.style.backgroundColor = "green";
    }
}

trackVisits.addEventListener("click", setColor);
setColor();

The code isn’t perfect, but shows how easy it is to modify the Out-Out-iFrame.
You may want to modify the colors to protect your visitors eyes :smile:

PS: This is a wiki, so everyone is welcome to edit and improve the post

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 13999

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>