Using Google Analytics 4, Google Ads, and Google Tag Manager
A guide on how to setup up and utilize these 3 tools to track user actions, measure conversions, and achieve your goals.
Introduction
One night, while I was analyzing comidaforfamilias.com’s Google analytics, I saw a button in the admin page that said “GA4 Setup”. I clicked on it, and something that looked like a setup form showed up. Since it was something I was unfamiliar with, and I didn’t really care about learning something new at the moment (it was 11pm), I closed the form, and went on analyzing the website’s data.
The next day, I wake up to this email, and I think to myself, “oh great, now what did I do?” I then proceed to click the button, and it takes me to the same setup page, asking me what I want to name the property. I give it a name and then I see a screen that is similar to the original analytics page, but with different properties. I then begin to get really interested as to what Google Analytics 4 is and how I could use to optimize the website and accomplish the organization conversion goals.
The Concept
The best way to use Google Analytics 4 is with Google Tag Manager and Google Ads.
Google Tag manager makes it SUPER EASY to track and manage events within your app or website and sends the information as tags to wherever you need them. You can then use these tags to track conversions which can then be used to optimize your Google Ads and report events for your analytics. And as long as you have Google Tag Manager in your websites <head> element then you won’t ever have to go into your website’s code again.
What is Google Analytics 4?
If you haven’t updated your Google Analytics account since October 2020, you are missing out on Google Analytics 4: Enhanced Analytics.
There are 3 key differences between Universal Analytics (UA) properties and Google Analytics 4 (GA4) properties. The first one being that UA is a session-based data model while GA4 is a flexible event-based data model. This means that UA measures user interactions with your website that take place within a given time frame. Which is good, but GA4 event-based data model takes it a step further and tracks what is happening inside your app or website, such as what pages are being viewed and what events are occurring (clicks, signups, etc.).
UA also has Limited cross-device and cross-platform reporting, while GA4 has full cross-device and cross-platform reporting. So with GA4, you are able to track user’s actions across devices.
Lastly, GA4 automatically utilizes machine learning throughout to improve and simplify insight discovery.
Website Set-up
NOTE FOR REACT.JS DEVELOPERS: Every time it says to copy and paste a code snippet to the <head> of your website, you only need to add the code to the head of your index.html file.
Google Analytics 4
To set-up Google Analytics 4, first go to your original Analytic account and go to admin. In admin, go to GA4 Setup Assistant and click on “Get Started”. You should then see a modal pop-up with the button “Create Property”. Click on that button.
Once you see the screen below, you can either click on Tag Installation or “Data Streams”, they will take you to the same place. There should be a stream that is already created, but if there isn’t just create a new one, and then click on it.
This will take you to the Web Stream Details page. You can then do one of the following to start collecting data:
- Copy and paste the global site tag to the <head> element of your website. (See example below.)
- Connect your GA4 site tag with your UA analytics
<! — Global site tag (gtag.js) — Google Analytics →
<script async src=”https://www.googletagmanager.com/gtag/js?id={MeasurementID}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag(‘js’, new Date());gtag(‘config’, ‘{MeasurementID}’);
</script>
Google Tag Manager (GTM)
To add Google Tag Manager with your website, create an account and a container. You will then be taken to another page and a modal will pop-up with the following instructions:
Paste this code as high in the <head> of the page as possible:<!-- 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','{ContainerID}');</script>
<!-- End Google Tag Manager -->Additionally, paste this code immediately after the opening <body> tag:<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id={ContainerID}"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
If you have already created a Google Tag Manager and just happened to forget to implement the script to your website, you can always find it in Admin → Your Website Container → Install Google Tag Manager
Done with Code
Congratulations you are done with setting up Google Tag Manager and Google Analytics onto your website!
“What about Google Ads?” - Some of you may ask.
Well, with Google Ads you have a choice: you can manually add the code snippets for each conversion (as it was done in the ‘old’ days) OR you can set up conversions with Google Tag Manager. I would suggest that you do the latter because if you were to do the first way, you would have to copy and paste code snippets for every conversion that you would want to track.
Google Ads
To track conversions in Google Ads, you would go to “Tools and Settings” in the top-center of the screen and then click on “conversions” which can be found under the MEASUREMENT column. Then click on “New Conversion Action”. The type of conversion that I am showing you how to track events on your website, so click on website and from here you would create the conversion action by filling in the following:
Goal and action optimization: This is to group your actions and segment your campaign reports. So for example, if I wanted to measure when someone clicks on a button that would take them to my app on the app store, I would categorize that as an outbound click.
Conversion name: Just give the conversion a name, like “app download”, or “application form submission”
Value: This depends on how valuable your conversion is. Since downloading an app isn’t very valuable and the value doesn’t change, you can select “use the same value for each conversion” and set the value to 0.01. However, if you have an e-commerce store where there are different values for products, it would be best to click on the 2nd option and then set a default value (you will give different values to your products later).
What about the 3rd option? Google doesn’t recommend that you use the third option, because “a value helps you measure the impact of your ads”. With that being said, even if the action is an outbound click, I would still suggest you give it a value.
Count: Do you want every click to be counted or do you only want to count the first time they interact with it. I selected every click, because maybe the user wants to go back to the website and click it again to share where they can find the app with a friend. However, if it is something that can only be counted once, like submitting a form, the 2nd option would be better.
Once you have created your conversion action, it will then give you an option as to how you want to setup the tag. If you have a webmaster, well, lucky you, you can just send them the code snippet and they will take care of it for you.
However, for the rest of us we have to decide whether to add the tag to the website code or install the tag using Google Tag Manager.
GTM Configuration
Creating a GTM Tag for Google Ads
I am going to spare you the copy and pasting of code snippets by skipping the first option and moving on to show you how to install with GTM.
Once you click on the 3rd option, you will see steps on how to setup the tag. Copy and paste the Conversion ID and the Conversion label to some place you won’t lose them (a spreadsheet, notepad, doc, etc., it’s a good way to be organized). You can then click continue, and don’t worry, you can always find it later in your conversion settings. Now go to your Google Tag Manager, and in the workspace (the default dashboard) click on “New Tag”. Now proceed with the following steps:
- Give your tag an obvious name. Something like “App Download” or “Form Submission”
- Click on Tag Configuration and Google Ads Conversion Tracking.
- Enter the Conversion ID and Conversion label that you saved from earlier and you can set Enable Restricted Data Processing to true. (If you have other information because you selected something different, you may fill the other fields in now too. The reason why I have you set it to true is to comply with the CCPA. Read more about it here.)
- Then create a trigger. A side page will slide from the right and present a list of default triggers, but if you have none created, click on the top-right hand corner where there is a blue plus button.
- Give your new trigger a name and then click on “Trigger Configuration”.
- Here you can choose a trigger type. This can range from viewing a page, clicking a link, to seeing how much a user scrolls. For this example, we are going to focus on clicks.
- It will then ask you if you want the trigger to fire on all clicks or on some clicks. Click on some clicks because we want to track only the app download clicks.
- You will then see 3 dropdown fields show up. The first is what is it looking for. You can be as broad as to what page is it looking for or the elements of the button that you want to trigger, or be very specific like the button id or link url (button url). You can then set whether you are looking for an exact match or if it just “contains” a value. Then set what you want the value to be. For example, I have a button with the id app-download, so I will have the following [Button Id contains app-download.]
- Once you have your trigger set, then click on the blue “Save Changes” button on the top-right corner.
Ta-da! You have set up your Google Ads conversion Tag in GTM!
Creating a GTM Tag for Google Analytics
Next, let’s setup 2 tags for google Analytics. One for Universal Analytics and another for the GA4.
Universal Analytics
In this example, we are just going to create a tag that triggers whenever a page is viewed.
- Create a new tag and give it a name.
- Then in Tag Type select “Google Analytics: Universal Analytics”
- Select a Track Type. For this example we are going to select page view.
- In Google Analytics Setting create a new variable and name it something that refers to your website’s UA.
- In the variable configuration you can hover over the question mark to find the Tracking Id or go to your UA account page → Admin → Select an account from the menu in the ACCOUNT column → Select a property from the menu in the PROPERTY column → Under PROPERTY, click Tracking Info → Tracking Code. (ref: https://support.google.com/tagmanager/answer/9207621#ga_id)
- Leave Cookie Domain set to auto and then click save on the top-right hand corner
- For the trigger, you can just set the page to all pages.
- Click Save and then you’re done!
Google Analytics 4
There are two steps to setup GA4 in GTM. The first is setting up GA4 Configuration. Here is the procedure:
- Create a new Tag and give it a name.
- Then in Tag Type select “Google Analytics: GA4 Configuration”
- Enter the Measurement Id that can be found in Google Analytics: GA4 dashboard in Admin → Select a property from the menu in the PROPERTY column → Under PROPERTY, click Data Streams→ Select the data stream that you created from the beginning → copy the Measurement ID near the top-right corner.
- For the trigger, set it to all pages.
- Click Save and then you’re done!
Now to measure GA4 events:
- Create a new Tag and give it a name.
- In Tag Type select “Google Analytics: GA4 Events”.
- Enter the Configuration Tag for GA4. This was the tag that you created in the steps before.
- For event name, give the event a name. Please note that this will show up in Engagement → Events (see below). (I wanted to point this out because I thought it was to name for type of events, so I put “Clicks”. In the image you can see this mistake in row 7 and 8 [ the 2 event names called clicks].)
- For the trigger, set it to what you had for Google ads or you can track another event.
- Click Save and you are done!
Conclusion
To recap, it is best to use Google Tag Manager to measure page views, events, and track conversions. You only have to install the snippets of code from Google Analytics and Google Tag Manager into your website once, and then you can create a tag and trigger in GTM to report to GA4 and Google Ads based on views and interactions on your app or website. This will then help you identify where users spend most of their time and how they engage in your interface.
I will be creating a video tutorial on how I did this soon. In the mean time, like and follow this page for more educational content. Leave a comment if this worked for you or if there was anything that you would like to share.