How can I store Google Analytics conversion code? - google-analytics

So let me rephrase and give a bit more detail. So basically I have a single site but I run the site in a production and UAT environment, separately. The production website uses Google Analytics and the UAT does not and my current development workflow is dev -> uat -> production. I do not want the analytics to be active for UAT, so I have a choice of either removing the script tags when the site is moved from uat to production or to build logic that will render the scripts when the Google Analytics is required.

I don’t understand your request, but if you are going to install the tracking code Past all your tags to the production website. You can use manual tagging or Google Tag Manager.

Related

Google Tag Manager Broken In Prod

I have been using GTM with GA4 for a few weeks now without much issue to track various metrics on my companies website. I have had GTM and GA4 working in the past locally, in our dev environment, and within our prod environment. After pushing updates from dev to prod, GTM has broken and will not connect to the prod website. The only error that I get is a 404 that GTM could not load. The same code is working locally, as well as on the dev site, this error only occurs on prod. I know my GTM is published, but I don't know why it has broken our prod site. I can't find many related answers that don't just say "publish your tag manager".
I have checked and rechecked the dev and local sites. I have checked that GTM is published. It is only within prod that I get the 404 error while connecting to googletagmanager.com.
yes, usually you get a 404 when the container is not published.
In your case, however, it may be something like forgetting to include the GTM script in your CSP.
Make sure you have the correct GTM id in your code.

Does google automatically index Firebase hosted sites?

I'm relatively new to Firebase Hosting. I have a web app that I'm working on and I have 2 Firebase Projects setup: 1 for my Production environment and 1for my Staging environments.
Ideally, I would want my Staging environment to NOT be indexed by Google.
Does anybody know if Google crawls Firebase hosted sites by default? If so, is the best way to prevent that to add a robots.txt that disallows all?
Any information would be much appreciated.
I don't think Google treats a web app hosted on firebase any differently than a web app hosted anywhere else; Google automatically indexes everything it can find. Officially, Google finds websites by looking for links and sitemaps. So, if your staging environnement is not linked to anywhere and you don't submit a sitemap directly to Google, in theory you shouldn't get indexed.
But, I wouldn't just count on the fact that you're not putting links out there. Links might find themselves online for some reason at some point in the future.
You could add a robots.txt to your staging site with this value:
User-agent: *
Disallow: /
But in my experience, an even better solution is to make your staging site unaccessible without a username/password. That way, Google's bot won't be able to index anything else than a login form. And if people do find your staging URL, they won't be able to see what's going on there.
Most people actually try hard to be indexed very high and it's not that simple. Since your goal is to NOT rank high, should be very easy. It's like trying to not win a game.

How to change environments with google optimize

Anyone know how to switch environments in Google Optimize.
currently google optimize is set to a production environment mySite.com.
Do I need to create a new account for my dev environment by editing container information, or can I just edit the property name under Google Analytics to match my Dev Analytics ?
Container setup >
Container information
mySite.com
XXX-xxxxxxx
Google Analytics
Property
myWebsite
XX-xxxxxxxxx-xx
Views
Master View

Is there a way to stop AMP Analytics counting development work as hits?

I have added AMP Analytics (amp-analytics) to my AMP Pages like these and the hits are recorded properly on Google Analytics. The only problem is that it is counting all my development work as hits. This will really skew my readings as many people work on the development version.
Is there a way similar to that in this answer where I can make this script run only if it's in the production domain?
You can use a filter in the Analytics view settings to exclude hits from the development environment (i.e. by hostname or page path).

how to verify that google analytics is working correctly on a subdomain (no access to root domain)

I am trying to add google analytics to a project that is located under a subdomain. The subdomain has been was pointed to my my project by the domain owner, so I do not have access to the domain itself.
When I add the tracking code the status (shown under Property > Tracking Info)
Status: Tracking Not Installed
Last checked: 04-Jan-2014 00:00:05 PST
The Google Analytics tracking code has not been detected on your
website's home page. For Analytics to function, you or your web
administrator must add the code to each page of your website.
Is there any way to verify the tracking code is installed on the subdomain without having to access the domain root?
Although the tracking status is uninstalled, I am getting activity in Standard Reports > Realtime.
Does this mean that it is working despite the status report?
Am I likely to get correct tracking information with this setup?
You do not need access to the root domain and if the realtime statistics track traffic then most likely your GA setup works correctly. Most likey you did not implement the code at the place in the source code where Google expects it (which usually works but is still flagged as an error in verification).
If you use Google Chrome as browser you can additionally use two nice extensions to verify that your setup is correct:
Google Tag Assistant - verifys various Google Tags without mch detail
Google Analytics Debugger - provides some detail which data is sent to google, which plugins (e.g. ecommerce) are loaded by the analytics code etc.

Resources