Struggling with Cookie Jar 2.0

Hi everybody,

just recently purchased Cookie Jar 2 to finally sort my privacy issue properly. I have set it up in a test file and it works up to the point java code comes into play. I tried the standard Google code (stripping out script tags, although that didn’t always feel right):

async src=“https://www.googletagmanager.com/gtag/js?id=UA-C201XXXX-Y
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag(‘js’, new Date());

gtag(‘config’, ‘UA-C201XXXX-Y’);

  • but as soon as that code is in it’s box, the cookie warning stops appearing altogether, just as if it wasn’t there at all. I have no coding experience, so I would appreciate a

Not sure if this helps, but are you using Safari and did you previously accept the use of cookies?

I don’t have cookie Ja, but for anyone to debug code for you, it would help. if the had a URL.

Seeing what you pasted into the site doesn’t help much.

BTW: please select and mark code so it prints correctly on the forum. You can use the </> button at the top or ⌘ Cmd+⇧ Shift+C.

Hi,

thanks for your reply. I mostly use RW to preview at this stage, as there is really nothing on the page yet. Following your post, I did try Safari, but it really behaves the same way, i.e. as soon as the code is copied in, it stops working. Take out the code and the rest will be back instantly. After fiddling around with it some more, it seems to the Cookie Jar might be very sensitive to syntax (which, unfortunately, I know nothing about).

Adding something as simple as
alert("Test This");
in the ‘Other Code’ section (hope I did that right this time), seems to work as long as there’s no other (faulty) code in there or the ‘Analytics Code’ box.

I then added the Google code to the ‘Analytics Code’ section. After stripping out the script tags, it looks like this:

    var gaProperty = 'UA-92012714-1';
var disableStr = 'ga-disable-' + gaProperty;
if (document.cookie.indexOf(disableStr + '=true') > -1) {
	window[disableStr] = true;
}
function gaOptout() {
	document.cookie = disableStr + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
	window[disableStr] = true;
	alert('Das Tracking durch Google Analytics wurde in Ihrem Browser für diese Website deaktiviert.');
}
async src="https://www.googletagmanager.com/gtag/js?id=UA-92012714-1"

						window.dataLayer = window.dataLayer || [];
						function gtag(){dataLayer.push(arguments);}
						gtag('js', new Date());
						gtag('config', 'UA-92012714-1', { 'anonymize_ip': true });

Before it looked like this:

   <script>
var gaProperty = 'UA-92012714-1';
var disableStr = 'ga-disable-' + gaProperty;
if (document.cookie.indexOf(disableStr + '=true') > -1) {
	window[disableStr] = true;
}
function gaOptout() {
	document.cookie = disableStr + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
	window[disableStr] = true;
	alert('Das Tracking durch Google Analytics wurde in Ihrem Browser für diese Website deaktiviert.');
}
</script>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-92012714-1"></script>
					<script>
						window.dataLayer = window.dataLayer || [];
						function gtag(){dataLayer.push(arguments);}
						gtag('js', new Date());
						gtag('config', 'UA-92012714-1', { 'anonymize_ip': true });
</script>

However, once any of these versions are in the ‘Analytics Code’ box, the stack disappears completely in either RW preview or Safari preview. Take the code out and it will be back.

Oh, and the link is: www.eat-drink-cook.com/testv3/index.html

Many thanks, Matthias

I don’t know what the " ‘Analytics Code’ box" is?
So I don’t have a clue where you are putting the code?




I don’t use google for anything, but it looks like you are trying to use tag manager?
My understanding of tag manager is that you leave the script tags in place and place the script in the head section.

I took a quick look and the sample code that google shows on their instructions looks nothing like what you are displaying. So you will need to show me where you got that code from. It has errors as displayed.

This is what Google’s documentations shows:

Copy the following JavaScript and paste it as close to the opening tag as possible on every page of your website, replacing GTM-XXXX with your container ID:

<!-- Google Tag Manager -->
<script>
(function (w, d, s, l, i) {
w[l] = w[l] || [];
w[l].push({
'gtm.start': new Date().getTime(),
event: 'gtm.js'
});
var f = d.getElementsByTagName(s)[0],
j = d.createElement(s),
dl = l != 'dataLayer' ? '&l=' + l : '';
j.async = true;
j.src =
'https://www.googletagmanager.com/gtm.js?id=' + i + dl;
f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'dataLayer', 'GTM-XXXX');
</script>
<!-- End Google Tag Manager -->

I don’t use Google anything, so if you are trying to do something different, you must be more specific.

From the instructions, if it’s for a single page (The tag changes for different pages) then leave the script tags along and place the code in the page inspector’s head section:
2021-01-11_10-34-02

If it’s site wide:




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