Google Analytics and Sharepoint Online - google-analytics

I would like to know how and where to add this code to SharePoint and start tracking usage via Google Analytics. I've seen conflicting information about adding to the master page and . When I reupload to Master Pages and Page Layouts the changes are not shown. Can anyone help please?
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-xxxxx"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-xxxxx);
</script>

If you are using the classic pages, you should be able to add your script to the head tag of your masterpage and publish.
If you're using the modern pages, you might be able to use the SPfx extensions.

Related

Google analytics script not found while checking SEO

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-TWEZSMMQHV"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-TWEZSMMQHV');
</script>
This is the code that I'm using in elementor that I got from Google Analytics. I'm using the insert headers and footers plugin to put the code and have already pasted it in the head section of it. I even tried through the custom code that elementor provides. Can someone please look into it and lemme know why it's being detected, even the source code has the code....

Multiple installations of Global site tag (gtag.js) detected

I have added the gtag like following
<!-- Global site tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-189297876-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-xxxxxxxxx-x');
gtag('config', 'G-xxxxxxxxxx');
gtag('config', 'AW-xxxxxxxxx');
</script>
Here I use the Google Analytics, the AdWords Conversion and the Global-ID.
When I check it with the Google Tag Assistant Plugin of Chrome, I get
I don't know, if this is a problem (the Message "Multiple installations of Global site tag (gtag.js) detected"). Is it only there one time.
If your website is SPA (Single Page Application) it is a normal (known) behavior of the extension.
When you add the Google Ads key to your gtag.js configuration
gtag('config', 'AW-xxxxxxxxxx');
it automatically adds a new tag to your DOM like:
<script type="text/javascript" async="" src="https://www.googletagmanager.com/gtag/js?id=AW-XXXXXXX&l=dataLayer&cx=c"></script>
I'd know why but it is. I found it with trial and error ;)

Google tag assistant reports: “Same web property ID is tracked twice”when trying to install google analytics code

I was trying to install google analytics code into our google tag manager at first I installed the GTM and add a tag that I grabbed from tracking ID and after all that, it doesn't seem to appear an analytical dashboard on my account.
I was wondering how do I fix this error on Google tag assistant and also to have the dashboard appear. thank you so much.
page script
script below
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-171638252-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-171638252-1');
</script>
Errors shown as below image,
This double-tracked ID's behaviour could be caused if you have loaded your tracking code both inline on the website, and through GTM as well. Please make sure that you do not load your tracking both inline on the website, and through GTM. This is my initial guess so far, unfortunately, I could not give you a final solution to this issue without seeing the source code and domain.

Refusing Google Analytics cookies for GDPR with Wordpress

This is a new problem I never faced before.
I have a website made with Wordpress. In this site I want to include Google Analytics, so I added the following snippet into my <head>. (With the proper UA, of course)
<!-- Global Site Tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXXX-X"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'UA-XXXXXXXXX-X');
</script>
Now, when the page loads, the following cookies are set automatically: _ga, _gat_gtag_UA_XXXXXXXXX_X and _gid
Now, I need to show the users an option to either accept or refuse cookies when visiting my site. For that I choose Cookiebot, to see this dialog.
But when the site opens, before the user had any chance to click either button, the cookies are already set.
Why is this? Am I misunderstanding anything about how cookies/GDPR work?

using global site tag (ga gtag) code for custom tags

Can this one gtag code from GA be used for own tags, or does tag manager need another tag on each page?
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=xxxx"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', xxx');
</script>
As per Google Analytics documentation:
To install the global site tag, copy the following code and paste it immediately after the tag on every page of your site. Replace GA_MEASUREMENT_ID with the ID of the Google Analytics property to which you want to send data. You need only one global snippet per page.
https://developers.google.com/analytics/devguides/collection/gtagjs#install_the_global_site_tag

Resources