Add code to header for Quantcast

Hello i want to add this code`

<style>
    .qc-cmp-button {
      color: #ff2a13 !important;
    }
    .qc-cmp-button.qc-cmp-secondary-button {
      color: #ff2a13 !important;
    }
    .qc-cmp-button.qc-cmp-button.qc-cmp-secondary-button:hover {
      color:#ffffff !important;
    }
    .qc-cmp-button.qc-cmp-secondary-button {
      border-color: #eee !important;
      background-color: #eee !important;
    }
        .qc-cmp-ui {
            background-color: #979696 !important;
        }
        .qc-cmp-publisher-purposes-table .qc-cmp-table-header {
          background-color: #979696 !important;
        }
        .qc-cmp-publisher-purposes-table .qc-cmp-table-row {
          background-color: #979696 !important;
        }
        .qc-cmp-vendor-list .qc-cmp-vendor-row {
          background-color: #979696 !important;
        }
        .qc-cmp-vendor-list .qc-cmp-vendor-row-header {
            background-color: #979696 !important;
          }
    .qc-cmp-small-toggle.qc-cmp-toggle-on,
    .qc-cmp-toggle.qc-cmp-toggle-on {
        background-color: #ff2a13 !important;
        border-color: #ff2a13 !important;
    }
</style>
` to my header but i cant find it also I am not sure if I install a child theme that I would have to build the site from the beggining can you please help me.

Hi George,

Thanks for reaching out.

You should install child theme for every customization that requires PHP coding. Please check this https://theme.co/apex/forum/t/setup-how-to-setup-child-themes/57. Then please add this code to child theme’s functions.php

add_action('wp_head', 'my_embed_code', 999999999);

function my_embed_code() { ?>

<!-- Quantcast Choice. Consent Manager Tag -->
<script type="text/javascript" async=true>
var elem = document.createElement('script');
elem.src = 'https://quantcast.mgr.consensu.org/cmp.js';
elem.async = true;
elem.type = "text/javascript";
var scpt = document.getElementsByTagName('script')[0];
scpt.parentNode.insertBefore(elem, scpt);
(function() {
var gdprAppliesGlobally = true;
function addFrame() {
if (!window.frames['__cmpLocator']) {
if (document.body) {
var body = document.body,
iframe = document.createElement('iframe');
iframe.style = 'display:none';
iframe.name = '__cmpLocator';
body.appendChild(iframe);
} else {
// In the case where this stub is located in the head,
// this allows us to inject the iframe more quickly than
// relying on DOMContentLoaded or other events.
setTimeout(addFrame, 5);
}
}
}
addFrame();
function cmpMsgHandler(event) {
var msgIsString = typeof event.data === "string";
var json;
if(msgIsString) {
json = event.data.indexOf("__cmpCall") != -1 ? JSON.parse(event.data) : {};
} else {
json = event.data;
}
if (json.__cmpCall) {
var i = json.__cmpCall;
window.__cmp(i.command, i.parameter, function(retValue, success) {
var returnMsg = {"__cmpReturn": {
"returnValue": retValue,
"success": success,
"callId": i.callId
}};
event.source.postMessage(msgIsString ?
JSON.stringify(returnMsg) : returnMsg, '*');
});
}
}
window.__cmp = function (c) {
var b = arguments;
if (!b.length) {
return __cmp.a;
}
else if (b[0] === 'ping') {
b[2]({"gdprAppliesGlobally": gdprAppliesGlobally,
"cmpLoaded": false}, true);
} else if (c == '__cmp')
return false;
else {
if (typeof __cmp.a === 'undefined') {
__cmp.a = [];
}
__cmp.a.push([].slice.apply(b));
}
}
window.__cmp.gdprAppliesGlobally = gdprAppliesGlobally;
window.__cmp.msgHandler = cmpMsgHandler;
if (window.addEventListener) {
window.addEventListener('message', cmpMsgHandler, false);
}
else {
window.attachEvent('onmessage', cmpMsgHandler);
}
})();
window.__cmp('init', {
'Language': 'el',
'Initial Screen Title Text': 'Σεβόμαστε την ιδιωτικότητά σας',
'Initial Screen Reject Button Text': 'ΔΕ ΣΥΜΦΩΝΩ',
'Initial Screen Accept Button Text': 'ΣΥΜΦΩΝΩ',
'Initial Screen Purpose Link Text': 'Εμφάνιση σκοπών',
'Purpose Screen Title Text': 'Σεβόμαστε την ιδιωτικότητά σας',
'Purpose Screen Body Text': 'Μπορείτε να ορίσετε τις προτιμήσεις συγκατάθεσης σας και να καθορίσετε τον τρόπο με τον οποίο θέλετε να χρησιμοποιηθούν τα δεδομένα σας, με βάση τους παρακάτω σκοπούς. Μπορείτε να ορίσετε τις προτιμήσεις σας για εμάς, ανεξάρτητα από αυτούς τους τρίτους συνεργάτες. Κάθε σκοπός έχει μια περιγραφή, έτσι ώστε να ξέρετε πώς χρησιμοποιούμε τα δεδομένα σας εμείς και οι συνεργάτες μας.',
'Purpose Screen Vendor Link Text': 'Εμφάνιση παρόχων',
'Purpose Screen Cancel Button Text': 'Άκυρο',
'Purpose Screen Save and Exit Button Text': 'Αποθήκευση και έξοδος',
'Vendor Screen Title Text': 'Σεβόμαστε την ιδιωτικότητά σας',
'Vendor Screen Body Text': 'Μπορείτε να ορίσετε τις προτιμήσεις συγκατάθεσης για τους επιμέρους τρίτους συνεργάτες με τους οποίους συνεργαζόμαστε, παρακάτω. Επεκτείνετε το στοιχείο λίστας κάθε εταιρείας, για να δείτε τους σκοπούς για τους οποίους χρησιμοποιούν τα δεδομένα σας, ώστε να κάνετε την επιλογή σας. Σε ορισμένες περιπτώσεις, οι εταιρείες μπορεί να χρησιμοποιήσουν τα δεδομένα σας χωρίς να ζητήσουν τη συγκατάθεσή σας, με βάση τα νόμιμα συμφέροντά τους. Μπορείτε να κάνετε κλικ στους συνδέσμους της πολιτικής απορρήτου τους για περισσότερες πληροφορίες και για να εναντιωθείτε σε αυτή την επεξεργασία.',
'Vendor Screen Accept All Button Text': 'ΑΠΟΔΟΧΗ ΟΛΩΝ',
'Vendor Screen Reject All Button Text': 'ΑΠΟΡΡΙΨΗ ΟΛΩΝ',
'Vendor Screen Purposes Link Text': 'Πίσω στους Σκοπούς',
'Vendor Screen Cancel Button Text': 'Άκυρο',
'Vendor Screen Save and Exit Button Text': 'Αποθήκευση και έξοδος',
'Initial Screen Body Text': 'Εμείς και οι συνεργάτες μας χρησιμοποιούμε τεχνολογίες, όπως cookies, και επεξεργαζόμαστε προσωπικά δεδομένα, όπως διευθύνσεις IP και αναγνωριστικά cookies, για να προσαρμόζουμε τις διαφημίσεις και το περιεχόμενο με βάση τα ενδιαφέροντά σας, για να μετρήσουμε την απόδοση των διαφημίσεων και του περιεχομένου και για να αποκτήσουμε εις βάθος γνώση του κοινού που είδε τις διαφημίσεις και το περιεχόμενο. Κάντε κλικ παρακάτω για να συμφωνήσετε με τη χρήση αυτής της τεχνολογίας και την επεξεργασία των προσωπικών σας δεδομένων για αυτούς τους σκοπούς. Μπορείτε να αλλάξετε γνώμη και να αλλάξετε τις επιλογές της συγκατάθεσής σας ανά πάσα στιγμή επιστρέφοντας σε αυτόν τον ιστότοπο.',
'Initial Screen Body Text Option': 1,
'Publisher Name': 'ECOBEST',
'Publisher Logo': 'https://ecobest.gr/wp-content/uploads/2019/07/logo-ecobest-white-background24.png',
'Display UI': 'always',
'Publisher Purpose IDs': [1,2,3,4,5],
'Consent Scope': 'service',
'UI Layout': 'banner',
});
</script>
<!-- End Quantcast Choice. Consent Manager Tag -->
<style>
.qc-cmp-button {
color: #ff2a13 !important;
}
.qc-cmp-button.qc-cmp-secondary-button {
color: #ff2a13 !important;
}
.qc-cmp-button.qc-cmp-button.qc-cmp-secondary-button:hover {
color:#ffffff !important;
}
.qc-cmp-button.qc-cmp-secondary-button {
border-color: #eee !important;
background-color: #eee !important;
}
.qc-cmp-ui {
background-color: #979696 !important;
}
.qc-cmp-publisher-purposes-table .qc-cmp-table-header {
background-color: #979696 !important;
}
.qc-cmp-publisher-purposes-table .qc-cmp-table-row {
background-color: #979696 !important;
}
.qc-cmp-vendor-list .qc-cmp-vendor-row {
background-color: #979696 !important;
}
.qc-cmp-vendor-list .qc-cmp-vendor-row-header {
background-color: #979696 !important;
}
.qc-cmp-small-toggle.qc-cmp-toggle-on,
.qc-cmp-toggle.qc-cmp-toggle-on {
background-color: #ff2a13 !important;
border-color: #ff2a13 !important;
}
</style>

<?php }

Hope this helps.

I am not sure how child theme work, if I install will I have to re-build something to my website or it will be just like before ? Thanks for previous reply.

Hi George,

No, you don’t need to re-build your site to install a child theme. A child theme is like the extension of the theme where you can add your own customizations and functions like the Quantcast code that you’re trying to add. Please follow the links below for more details.

What is a Child Theme
Customizations - Best Practices
How To Setup Child Themes

Hope it helps,
Cheers!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.