Hey there, I’m Benjamin from Loves Data.
In this video, you will learn how to get started with server-side tagging in Google Tag Manager.
This is a new feature that Google has released.
It lets you move tracking tags, like Google Analytics, from client-side to server-side.
Okay, so what does that mean?
Well, instead of the Google Analytics tag loading in the web browser for each visitor
to your website, tags can run on your server.
This means that Google Tag Manager server-side tagging can improve the performance of your
website by reducing the number of javascript tags you use.
And apart from improved performance, server-side tagging also gives you greater control of
the data that is sent to the different analytics and advertising platforms you are using.
Okay, it’s time to get started!
We need to create a new container in Google Tag Manager.
I’m going to create a new container in my existing Google Tag Manager account, so I’m
going to select the three vertical dots ... And I’m going to select ‘Create Container’...
Now we need to name our container.
I’m going to call mine ‘Loves Data’, ‘server-side demo’...
Then we need to select ‘Server’...
And then we click ‘Create’...
We’re now prompted to set up our tagging server on Google App Engine.
We can see there is an option to automatically provision our tagging server on App Engine,
or we can set it up manually on App Engine.
Let’s leave the default option selected and click the ‘Automatically Provision Tagging
Server’ button ... When we first set up our tagging server we will be using a single
server, so this will be free, however we still need to enter billing details in case we go
over the free limits.
For example, if you later decide to set up the recommended number of servers, which is
three servers, then we will be charged.
So let’s click ‘Create a billing account’...
We’re taken to Google Cloud Platform and we need to enter out billing details ...
Now we’re taken back to Google Tag Manager ... We can check that our correct billing
account is selected.
And we can click the button to create our tagging server ... One thing to flag is that
if you’re using G Suite, then you will need to make sure that ‘Google Cloud Platform’
is enabled for users in your G Suite account.
If it’s not enabled, then you will see an error message.
You will need to enable Cloud Platform before setting up the tagging server.
Okay, this can take a little while, so let’s skip ahead...
We can now see the details for our tagging server ... The main thing to highlight is
the ‘Default URL’.
This is where we will be sending our hits.
You will notice that it’s currently an appspot domain, so this is the first thing we will
want to change.
In order to take full advantage of server-side tagging we need to configure this so that
we’re using our own domain.
This lets us create first-party cookies for our website.
To configure our own domain, let’s start by heading to Google Cloud Platform ... Let’s
select ‘App Engine’...
And then ‘Settings’...
Now I’m going to select ‘Custom Domains’...
And then ‘Add a Custom Domain’...
Now I’m going to select ‘Verify a new domain’ from the drop-down menu.
This is because we want to configure our own subdomain to accept hits for our tagging server.
I’m going to enter ‘gtm’, ‘dot’, ‘analyticsbeta’, ‘dot’, ‘com’...
And then I’m going to click ‘Verify’...
Now I’m taken to Google Webmaster Central to verify that I own the domain.
You can select your domain name provider from the list ... Or scroll to the bottom and select
‘Other’...
We need to add a TXT record to our domain’s DNS.
So let’s copy the record ... And I’m using Cloudflare to manage my DNS, so let’s head
to Cloudflare ... The steps we’re about to follow will be similar for other providers,
but if you run into any problems, then I recommend contacting support for your domain name provider.
In Cloudflare, I’ve already selected my domain and then I’ve selected ‘DNS’...
Now I’m going to create a new record by clicking ‘Add Record’...
Let’s select ‘TXT’ as the record type ... Enter ‘gtm’ as the ‘Name’...
And then paste the value we copied from Webmaster Central ... Now I’m going to click ‘Save’...
And we can see the record has been added.
Now let’s head back Webmaster Central ... I can now click ‘Verify’...
We can see that our subdomain has been verified and we can now head back to Google Cloud Platform
... Let’s click ‘Refresh’...
And we can again see we’ve verified the subdomain ... And let’s click ‘Continue’...
I’m going to remove the ‘www’ version of the domain ... And let’s click ‘Save
Mappings’...
Let’s click ‘Continue’...
And now we need to add some more DNS records for our subdomain ... So we will need to copy
these ... And now let’s head back to Cloudflare ... I’m going to add a new record ... I
need to make sure it’s an ‘A’ record ... Enter my subdomain ... And then enter
the IP address provided by Google ... I’m also going to click ‘Proxied’ so that
it becomes ‘DNS Only’...
Now I’m going to click ‘Save’...
And repeat this for the other records ... And then for the AAAA records ...
Now we can head back to Google Cloud Platform ... And click ‘Done’...
A SSL certificate will now be created for our subdomain.
This can take a while, so let’s skip ahead ... Now let’s head back to Google Tag Manager
... We need to update Google Tag Manager with our custom subdomain, so let’s select ‘Admin’...
And then ‘Container Settings’...
Now we can update our tagging server URL.
Let’s change this to our subdomain ... And click ‘Save’...
Now let’s head back to the workspace ... And let’s select ‘Clients’...
This is the main difference you will notice between web containers and server-side containers.
A client in a server-side container listens for incoming data and makes that data available
to use in our tags.
We can see there are two default clients.
There is a client for data coming from a Universal Analytics tag and a client for data coming
from an App and Web property tag.
In this video we’re going to use data coming from an existing Universal Analytics tag.
Let’s select this client ... There are different changes you can make to the client.
These include changing the ‘Priority’ for the client.
Basically, if you have multiple clients listening for the same type of incoming data, then you
can control which client will accept the data first.
We’re going to leave this set to the default.
The other option I want to highlight is the ‘Activation Criteria’.
As I mentioned, I’m going to use an existing Universal Analytics tag in a Google Tag Manager
web container to send data to our server-side container.
However, if you’ve implemented the Google Analytics tracking code directly on your site,
then you might need to modify the ‘Activation Criteria’.
For example, if you’re using the ‘gtag.js’ version of the tracking code on your site,
then you would need to select this option.
Okay, let’s close the client ... We’re going to configure the server-side container
to pass a hit through to Universal Analytics and to also send data to an App and Web property.
So let’s select ‘Tags’...
And create a new tag ... Let’s name the tag ‘Google Analytics Universal Analytics’...
And let’s select ‘Tag Configuration’...
We can see there are only three in-built tags currently available for our server-side container.
These are Google Analytics tags for App and Web properties, for Universal Analytics, and
there is a HTTP request tag.
Let’s select ‘Universal Analytics’...
Since I’m going to be using a Universal Analytics tag to send data to this tag.
It means data will simply pass through this tag and we can leave all of the default settings.
However, we could modify the data before it is sent to Google Analytics.
For example, we could change the property ID, if we wanted the data to be sent to a
different Google Analytics property.
Or if we wanted data to be sent to multiple Google Analytics properties.
Now let’s select ‘Triggering’...
And let’s select the blue plus sign to create a new trigger ... Let’s name our trigger
‘Universal Analytics All Events’...
All triggers in server-side containers are custom, so we can leave this selection.
And we can then see that by default the trigger will fire on ‘All Events’.
This means that it will look for any event created by any of our clients and trigger
our tag.
Since we saw there was a Universal Analytics client and an App and Web client, we’re
going to change this, since we only want to trigger our tag for Universal Analytics events.
So let’s select ‘Some Events’...
And let’s select ‘Choose Built-In Variable’ from the drop-down ... Now let’s select
‘Client Name’...
Then ‘equals’...
And enter ‘Universal Analytics’...
This will mean that our tag only fires when a Universal Analytics event occurs.
Now let’s click ‘Save’...
And let’s save our tag ... So far we’ve created a single tag, so this means that we’re
simply passing data through our server-side container, at the moment it won’t be reducing
the code that we load on our website.
So let’s add another tag.
We’re going to use the same event, or inbound data from Universal Analytics to fire a second
tag in our server-side container.
Let’s add another tag ... Let’s name this tag ‘Google Analytics App and Web’...
Let’s select ‘Tag Configuration’...
And let’s select the ‘App and Web’ tag ... Since the inbound data will be for Universal
Analytics and I want the data to go directly to my App and Web property, I’m going to
add the ‘Measurement ID’ from my App and Web property ... Now I’m going to select
‘page_view’ as the ‘Event Name’...
Let’s select ‘Triggering’...
Since our existing implementation might be sending more than just pageviews to Google
Analytics, I’m going to create a new trigger to only fire the tag when pageview data is
coming through to our client.
So let’s click the blue plus sign to create a new trigger ... Let’s name the trigger
‘Universal Analytics Pageview Events’...
And let’s change the firing rule to ‘Some Events’...
Let’s select ‘Client Name’...
‘Equals’...
And enter ‘Universal Analytics’...
And now let’s click the plus sign ... Let’s select ‘Choose In-Built Variable’...
And let’s select ‘Query String’...
This will let us match values that are included in the hit.
Let’s leave ‘Contains’...
And then enter ‘t’, ‘equals’, ‘pageview’...
This will mean that the trigger only fires the tag for pageview hits.
Now let’s save the trigger ... And let’s save the tag ... We will now be using our
server-side container to listen for Universal Analytics data and then use this to send data
to both a Universal Analytics property and an App and Web property in Google Analytics.
Let’s click ‘Preview’...
A new tab opens to preview our tags for our server-side container.
One thing I want to highlight is that you need to ensure you’re using a single browser
window to preview your tags and your website.
You can’t debug your tags in separate browser windows.
We will come back to check our tags in a moment.
The next thing we need to do is modify our Google Tag Manager web container to send data
to our new server-side container, instead of directly to Google Analytics.
So let’s head to our web container ... We can see our web container has two tags,
one for Universal Analytics and another for App and Web properties.
So we’re going to start by modifying our Universal Analytics tag.
To do this I’m going to select ‘Variables’...
And then ‘Google Analytics’...
This is the Google Analytics settings variable used by my Universal Analytics tag.
Let’s select the variable ... And let’s select ‘Advanced Configuration’...
We now need to enter the URL we configured for our server-side container as the ‘Transport
URL’.
So I’m going to enter ‘https’, ‘colon’, ‘forward slash’, ‘forward slash’,
‘gtm’, ‘dot’, ‘analyticsbeta’, ‘dot’, ‘com’.
Now I’m going to save the tag ... Next, I’m going to select ‘Tags’...
And I’m going to pause the App and Web tag.
This is because we have replicated this tag in our server-side container, so we no longer
need to add this tag using our web container.
So let’s pause the tag ... Now let’s preview the changes ... I’m using demo accounts
for this walk-through, so if you’re making changes to your production (or live) website,
then you will need to ensure you upgrade your project in Google Cloud Platform first.
You will also want to test your implementation.
One way to do this is to create new Google Analytics properties and use these when testing
your server-side container.
Since all of my accounts are demo accounts, I’m happy to make these changes.
I’m going to head to my demo site ... And I’m going to reload the page to open the
Google Tag Manager debug console ... We can see that only a single tag has fired
on the page.
It’s our Universal Analytics tag.
Now let’s head back to the preview tab for our server-side container ... We can now see
that the incoming request has been captured by our server-side container.
And we can see that this has resulted in two tags being triggered.
We can see both our Universal Analytics tag and our App and Web tag has been triggered.
We will now be able to see data in our Google Analytics reports.
That’s it!
So that’s how you can get up and running with server-side tagging in Google Tag Manager.
Since this is a new feature in Google Tag Manager, we are currently limited to a very
small number of built-in tags.
There are currently tags for Google Analytics, including Universal Analytics and App and
Web properties.
And there is also a HTTP request tag.
This means that if you currently want to use server-side tagging for other platforms, like
Facebook, you will have to make your own tag template.
Otherwise, it’s a case of waiting until more built-in tags become available.
This means it’s a good time to start learning about Google Tag Manager server-side tagging,
so you’re ready when new tags are added and more features are released.
Are you going to start experimenting with server-side tagging?
I’d love to know!
Let me know in the comments below.
And if you found this video helpful please subscribe, share it with your friends, and
hit the like button so I know to make more videos like this.
See you next time!