Fix Google Analytics Cookie Consent Code

Job ID: 39288230

Budget: €8 – €30 EUR

For the consent tool to work, changes must be made to the website code in the Google Analytics / Google Tag Manager tag:

All script tags that set third-party cookies must be provided with the attribute data-cookiecategory="..."

The value of the attribute must be selected to match the respective tool
(analysis tool => data-cookiecategory="Google Analytics").

To allow visitors to subsequently adjust the cookie settings, you can include a link to open the popup in your website (see example link to consent tool settings).

THIS IS THE SCRIPT in the header (source ID will be provided) and it does not work

<script data-cookiecategory="Google Analytics" src="..."></script>
<script type="text/plain" data-cookiecategory="Google Analytics">
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag("js", new Date());

gtag("config", "<google-analytics-tracking-id>", {
cookieDomain: "none",
});
</script>

TASK: so I need someone to fix this to only collect data when the cookies have been accepted by the user.