Thread Starter
pakino
(@pakino)
to clarify
I inserti this code in my function.pfp file in child-themes.
add_action( 'wp_head', 'my_google_opt_out' );
function my_google_opt_out() {
if ( ! has_consent( 'statistici' ) || ! is_allowed_cookie( '_ga' ) ) {
?>
<script>
window['ga-disable-UA-XXXXXXXX-X'] = true; // Don't forget to replace X for your actual UA numbers.
</script>
<?php
}
if ( ! has_consent( 'statistici' ) || ! is_allowed_cookie( '_gali' ) ) {
?>
<script>
window['gali-disable-UA-XXXXXXXX-X'] = true; // Don't forget to replace X for your actual UA numbers.
</script>
<?php
}
if ( ! has_consent( 'statistici' ) || ! is_allowed_cookie( '_gat' ) ) {
?>
<script>
window['gat-disable-UA-XXXXXXXX-X'] = true; // Don't forget to replace X for your actual UA numbers.
</script>
<?php
}
if ( ! has_consent( 'statistici' ) || ! is_allowed_cookie( '_gid' ) ) {
?>
<script>
window['gid-disable-UA-XXXXXXXX-X'] = true; // Don't forget to replace X for your actual UA numbers.
</script>
<?php
}
}
I setting this cookies _ga, _gali, _gat, _gid with name Statistici
end I create consentse Statistici..
Hi @pakino,
If all those cookies are for the same thing, you can check for only one of them.
Can you share your site with me?
Thread Starter
pakino
(@pakino)
I apologize, but I solved it. It was my mistake, a plugin was used, MonsterInsight, and therefore did not block cookies. Entering the analytics code directly works perfectly.
Thanks to the availability
Hi @pakino
I don’t understand where I should create “statistici”.
Thanks