[AUDIO LOGO]
MATT LANDERS: In this tutorial, we're
going to set up Google Analytics for the very first time.
What we're going to do is create a brand new Google Analytics
property, a brand new website, and then we're
going to put the code on the website
that we need to start sending events about what our users are
doing on the site to Google Analytics for processing.
We'll then jump into the UI for Google Analytics
and see some of the events and reports
that we get right out of the box.
All right, let's dive in.
[CHIME]
OK, now we're on the home page of our Google Analytics
property.
Now, I've already created a Google Analytics
account and a Google Analytics property.
And once you do that, you're going to end up
on a page that looks like this.
And it's going to be saying that, hey, we
don't have any data right now.
You need to set up a data stream.
And all that data stream is is a source
of data that we're going to feed into Google
Analytics for processing.
Then Google Analytics can use that data to provide us
with reports, which will in turn provide us
with insights about what's happening on our website.
OK, so there's a couple different type
of streams that we can create.
We can create a web stream or an app stream.
And for the purposes of these videos,
we're going to focus solely on websites.
So all we have to do is go down here and click Web,
and then we put in our web address.
So gatutorials.com.
But you can use your website address.
And I'll call it GA Tutorials Website as my stream name.
So that's the source of data that's
going to be provided for Google Analytics.
Also notice this enhanced measurement option here.
Now what that means is that Google Analytics can
automatically collect some events on our website,
like page views so that we can tell when a user goes from one
page to the next, whenever users are
clicking links or downloading files, watching videos--
all of that can be automatically collected for you.
So we're going to keep that enabled
because that's nice for us.
We don't have to do much more than get the tagging set up,
and then we get that functionality.
So we're going to go ahead and Create stream.
On the next dialogue, there's a couple of things
that we want to take note of.
First of all, we want to make sure all of our information
looks correct.
And then we're also going to look at this measurement ID.
We're going to need this ID for our tagging,
and our tagging is what we put on our website
to start sending the interactions and events that
are happening from our users to Google Analytics.
Without tagging, Google Analytics gets no data,
so we have to set that up.
And that's the next thing we're going to do.
If you look through this dialogue,
you'll see there's a lot of different options.
You can see our Google tag down here.
There are different ways that we can set up tagging.
For the purposes of this series, we're
going to focus on Google Tag Manager.
I believe that this is the best way
to set up tagging because it sets you
up for success in the future as well as right now, because you
can use Google Tag Manager to manage tags
for all different products, not just Google products.
So we're going to use that because I
think it's a great tool that we should be using.
All right, so let's go ahead and copy our measurement ID,
and then we'll head over to Tag Manager
and get our tagging set up.
We can get to Google Tag Manager directly from Google Analytics.
So if we click out of here and we go to the top,
this is the Tag Manager icon.
We're going to click on that and we'll say that--
it'll ask us to go to Google Tag Manager and get started,
so we're just going to do that.
We're going to open up a new tab,
and now we're at the Google Tag Manager home page.
And we need to create an account,
so let's go ahead and do that.
So I'm going to call this account my GA Tutorials,
and then I'm going to put in my website, gatutorials.com,
just like we did for Google Analytics.
And we'll click Web and say Create.
We're going to have to agree to some terms of service,
and then we'll get our tag and our container set up for us.
And the first thing that's going to pop up
is some code that we need to add to our website
so that Tag Manager can start working for us.
So what we're going to do now is we're
going to walk through an example of setting up Tag Manager
and Google Analytics within Tag Manager
in our code for our website.
Let's do it.
All right, so first thing that we need to do
is copy this script.
This one goes into the head-- the first one.
The second one goes into the body tag.
So we're just going to follow the instructions of exactly
what this is telling us to do.
I'm going to go over to my code editor, Visual Studio Code,
and I have a very, very simple website already set up,
which you'll see in a second.
So we'll go to our HTML page, and then
in the header of our HTML, we're going to paste this code.
So there we go.
We've got our code in here.
It copies our GTM ID over, which is the ID for our container.
So what's going to happen is that when our web page loads,
the script is going to run and it's going
to load our GTM container.
And then that container is going to load any other tags
that we've configured within it.
Let's go back over to the web and copy our body tag.
This is another script that we need.
We'll scroll down to the bottom of our body,
we'll paste that in and save it.
And now our container should be set up and ready to go.
But right now, we haven't configured anything
in Google Tag Manager to actually happen,
so let's go back over to Tag Manager and do that.
So we can close this, since we've set up our website.
And now we can go ahead and configure our tag
for Google Analytics.
So we go to our tags, we say New tag.
Go to our tag configuration, click Edit,
and you'll see that we have a Google Analytics GA4
Configuration.
And that's exactly what we want, so let's click on it.
When we do that, we're going to be
asked for our measurement ID.
Now this is the ID that we have over on our Analytics page.
So let's go here, back over to Google Analytics.
We'll copy our measurement ID from the top right of our web
stream, and then we'll paste that into Google Tag Manager.
We're going to leave everything pretty much at the default
here and just see what happens.
We do need a trigger.
We want this to load on every single page on our website.
And then Google--
Google Analytics is going to do the rest.
They're going to have all those enhanced measurement
events that we need.
And let's rename this tag to something relevant.
We'll call it GA4 Config for our website.
All right.
We'll save that, and then we need to submit and publish
these changes to our container.
And we're just going to publish them not adding descriptions.
It's all optional.
And we should be good to go.
So let's go over to our website and see
if everything is working.
This is our beautiful website, which
is a very simple demo account.
And keep in mind that all of the code that you're
going to see here is available on our GitHub.
So you can find this demo website on our GitHub
so that you can follow along with this example yourself.
All right, what we're going to do
is we're going to open the debug tool.
So on Mac, that's Command-Option-I. On Windows,
that's F12.
And we're going to go down to our Network tab
and see what happens whenever we refresh this page.
All right, what's going to happen
is we're going to see that our GTM container has loaded,
and we'll see that our Google Analytics tag is running.
You can see our measurement ID right there
in the Network panel.
So this is great.
This means that everything that we've done has actually worked,
and now we should be able to go into Google Analytics
and see our data.
So let's hop over and see if it's working.
I will close this and just go back to our homepage.
And now look, we've got a different homepage.
We don't have that alert telling us
that we need to set up our data stream.
This is good news.
It looks like we're working.
So we can go over to our reports and go to Realtime,
and we should be able to see that a user will show up here
in just a second.
OK, and then after just a couple of minutes,
we'll see that our data has been fed from our website
into our Google Analytics property.
And we can see that now we have one user on our website.
This is amazing.
That quickly, we were able to go set up
Google Analytics from scratch, put it on our demo website,
run it, and get data feeding into Google Analytics.
Hopefully that explains everything
that you need to get started on your own website.
And if you have any questions, please
feel free to leave a comment on this video.
Or join our Discord server and ask questions
to us and the community there, and we'll
be sure to answer your question.
Thank you for watching this video,
and I look forward to seeing you in future videos.
Happy measuring.
[AUDIO LOGO]