How To Implement Elevar’s GTM Server-Side Tracking

180 minutes
Difficulty

You’ll learn the step-by-step process of how to implement server-side tracking on your Shopify store utilizing Elevar’s Google Tag Manager […]

Brad Redding

Brad Redding is the Founder & CEO of Elevar. Specializing in analytics, tracking, GTM, and conversion optimization.

You’ll learn the step-by-step process of how to implement server-side tracking on your Shopify store utilizing Elevar’s Google Tag Manager server-side solution.

But before you can implement the Facebook Conversion API or other server-side tags, you need to create a server-side container in Google Cloud first.

Follow along the steps below to create your Google Cloud server, configure DNS, and launch your source & destinations.

Server-Side Tracking Lessons:

Overview

In this lesson, you will learn how to create your new server-side container in Google Tag Manager and connect it to your Google Cloud account.

Here are the steps you will complete:

  1. Create New Container in GTM
  2. Provision Your Server
  3. Connect Billing Account
  4. Create Billing Account (optional)
  5. Add Billing Information
  6. Tagging Server Setup Complete

 

 

Before getting started, you will want to have the following:

  1. Admin access to your Google Cloud account (if you have one)
  2. A verified domain that your email has been added to. Typically this is your primary website URL that is verified in Google Search Console.

Create GTM Container & Google Cloud Account

Step 1: Create New Container

Inside of Google Tag Manager go to Admin > Create New Container > Select Server Side Container Type:

create ss container

If you are on an Elevar advanced plan then be sure to add [email protected] to this container with “Publish” permissions inside Admin > User Management.

Google will set all users to Read Only by default after you create this container.

Step 2: Provision Your Server

Your next step is to have Google provision your new server. Click “Automatically provision tagging server” to continue.

How to create GTM Container part 1

Step 3: Connect Billing Account

If you already have a billing account with Google Cloud then you can select your billing account to continue.

Otherwise, you will need to create a new billing account which I’ll go through in the next few steps.

connect-billing-account

Step 4: Create Billing Account Details

This is the screen you’ll land on to create your basic account details.

create-new-billing-account

Step 5: Add Billing Information

Next, you’ll need to add your billing details including a credit card.

setup-billing-profile

Step 6: Tagging Server Setup Complete

Once you’ve added your billing information then Google will begin to provision your server.

If it’s successful (this takes a few minutes) then you’ll be prompted with this screen inside of Google Tag Manager:

server container successfully setup

If you have an error like this below then simply retry by clicking the create server button again.

SS-setup-error

That’s it! You’ve successfully created your new server-side container. Now it’s time to connect this to your own 1st party domain.

Upgrade Google Cloud Instance

If you are planning on running production tracking through your server-side container we recommend upgrading from your test instance to mitigate downtime.

When you create your server-side container for GTM, Google will automatically make this a “test” server instance when you can verify by going to Google Cloud > click the hamburger menu in the top left > App Engine > Versions:

appengine-version

If you plan on using this for your production tracking then we recommend upgrading this to minimize quota or throttling issues based on your volume of traffic.

Here is the cost of one customer that has the following setup:

  • Min server: 1, max server: 4
  • GTM proxy
  • Sitewide FB Conversion API
  • Google Analytics purchase conversion tracking
  • ~ 900K pageviews/month and ~ 600K events tracked via FB CAPI that are routed through server container

gcp-cost

How to Upgrade To Production Server

Watch this step by step video on how to complete this:

First, log into your Google Cloud instance connected to your GTM server-side container.

Many times you can access it through the GTM server container here:

How to create GTM Container part 2

Once you’re in Google Cloud connected to your GTM server-side container then follow these steps.

Step 1: Cloud Shell CLI

In order to upgrade, you’ll need to use the Cloud Shell CLI. Select the Cloud Shell

After enabling the shell, you’ll need to paste the following into the shell.

bash -c "$(curl -fsSL https://googletagmanager.com/static/serverjs/setup.sh)"

After pasting the code, hit enter > then select authorize. This will download an app engine installer from Google that assists in the server-side container setup.

Next, you’ll have to confirm that you are overriding the existing deployment.

Type y and hit enter.

If you’ve already set up an app engine instance you’ll already have the container config in the shell.

Please input the following information to set up your tagging server. For more
information about the configuration, input '?'. To use the recommended setting
or your current setting, leave blank.
Container Config (Current: asldkfjalsdfjadslfjdslk: ?
  The container config describes your server-side container. Copy it from
  Google Tag Manager.

If the container config doesn’t show, you’ll need to copy it from the GTM server-side container as shown here:

This typically displays if you’ve manually provisioned your GTM server container.

If the container config has a value you can hit enter to proceed through the wizard. You can continue through each step as shown below:

Step 2: Upgrade Server Setup

Hit enter to see the configuration setup in the cloud console below.

Container Config (Current: asldkfjalsdfjadslfjdslk):
Policy Script URL (Current: ''):
Request Logging (Current: on):
Deployment Type (Current: production): production
Autoscaling (Current: on): on
Minimum Number of Servers (Current: 1): 1
Maximum Number of Servers (Current: 2): 4
CPU Target Utilization (Current: 0.6): 0.6

Your configured settings are
Container Config: asldkfjalsdfjadslfjdslk
Policy Script URL: ''
Request Logging: on
Deployment Type: production
Autoscaling: on
Minimum Number of Servers: 1
Maximum Number of Servers: 4
CPU Target Utilization: 0.6
Do you wish to continue? (y/N):

As you can see, I’ve opted for a production deployment type with a minimum of 1 server and a maximum of 4 servers (but you can set this to any min/max amount that you want; Google recommends 3 minimum and 6 maximum. It will depend on your traffic volume).

The CPU target utilization is a measurement of the CPU’s usage which triggers another server to scale up if the current usage is above the target. The default is 60% which is recommended.

You can type “y” and enter to proceed with the deployment. It will take a few minutes and shouldn’t introduce any downtime.

Step 3: Verify Version is in Production Mode

Once this is complete (you’ll need to wait a few minutes) you’ll see your instance is in production mode:

gcp-production-version

That’s it!

You can use this same guide to make tweaks if necessary as you monitor your instance.

Once you’re done with the upgrade then you can continue onto the DNS setup which is the final step in our server-side setup process.

Configure DNS For Server-Side Container

!!!! WARNING !!!! If you do not follow steps 4-9 outlined below then you will take your website down. Please be sure you do not edit anything in your DNS related to your primary www domain. This is only for a new subdomain you create // END OF !!!! WARNING !!!!!

This is the second part of configuring your server side container. Before completing this guide, be sure you’ve completed the steps in creating your server side container.

This guide goes through every step required to:

  1. Create custom subdomain for your server side data collection
  2. Assign your unique subdomain to your server side container
  3. Verify the subdomain is working as expected

Before getting started you will want to have the following:

  1. A verified domain that your email has been added to. Typically this is your primary website URL that is verified in Google Search Console.
  2. Access to your DNS registrar (e.g. GoDaddy, Cloudflare, Network Solutions, etc.)

Remember – as we covered in the overview on server side tag management with GTM, you get data to your server side container by sending requests to a unique URL. And you want that unique URL to be a subdomain of your primary website URL so your server side tagging is done in 1st party context.

Step 1: Access Google Cloud Container

Go to your server side container in GTM.

  1. Then click your GTM Container ID on the top right corner of the screen.
  2. Inside the modal that contains your server information, click on the “Google Cloud Platform ID” link which will bring you to your Google Cloud account.

access-google-cloud

This will bring you to your Google Cloud App Engine page.

google-cloud-landing-page

FAQ: What Google Cloud Project should I be in? – Google auto-creates a project for you! You can verify you’re in the correct project by confirming that the project ID matches the project ID shown in Google Tag Manager > Click the GTM Container ID on Homepage > project ID listed under ‘Google Cloud Platform Project’.

Step 2: Navigate To Your App Engine

In this step you’ll need to click the hamburger menu and go to App Engine > Settings as shown here:

app-engine-settings

This should bring you to a page that looks like this:

go to app settings

Click on the Custom Domains tab to continue.

Step 3: Verify Your Domain

In the custom domain tab you’ll need to select a domain that you already have verified

OR verify a new domain.

verify-new-domain

If you have not verified a domain yet then enter the primary domain name you want to use

Example: If your domain is https://www.mydomain.com, then input mydomain.com.

If your email address is already a verified user of this domain in Google Search Console then you won’t need to do anything else and Google will verify your user.

However if you are not verified then Google will walk you through a step to verify your domain by adding a TXT record to your DNS settings.

You’ll likely see a screen similar to this:

webmaster tools

Now – this step can get confusing and frustrating. Some common issues we see in this step are:

  • The email you are logged into Google Cloud is not the same email that has Search Console access. In this case you can either verify this email with search console or add your email to search console.
  • Search console isn’t verified at all. If this is the case then go the TXT record route when verifying (which the Google verification will walk through).
  • If you do verify then you might need to way 20-30 minutes for Google Cloud to update. Refresh the page if needed.

If you’ve added a TXT record for your DNS settings then you’ll need to refresh the page to see the green checkmark that you’re verified.

Step 4: Continue With Verified Domain

Once you’ve verified your domain then click continue on your domain like the below:

select domain

!! This is a very important step. When you click continue from above you are going to be shown a similar screen as shown below. !!

gtm-ss-container-delete-primary-domains

By default Google is going to show your primary domain and www domain to “connect”.

YOU DO NOT WANT TO CONNECT THESE.

Sorry for the caps – but it’s that important.

X out the defaults they show you in the screenshot above.

The only domain you need to continue with is your subdomain that you’ll be using for your SS container.

The example below uses:

  • ssapi.domain.com

The subdomain (in bold) can be anything you want. Just don’t use your primary domain here.

Step 5: Create Subdomain URL

In this step you’ll add your custom subdomain which will be your server URL.

For example if I added getelevar.com as my verified domain name in the previous step and I wanted my subdomain to be “ssapi.getelevar.com” then I would enter “ssapi.getelevar.com” in the field shown below.

We recommend creating something unique for your business (i.e. don’t use collect).

*very important* – DO NOT USE WWW OR YOUR PRIMARY DOMAIN HERE! THIS WILL BREAK YOUR WEBSITE.

Screen Shot 2021-04-08 at 9.32.18 AM

Once you’ve saved your subdomain mapping in the previous step then you should see a green checkmark confirming your new subdomain for your server side container.

Screen Shot 2021-04-08 at 9.32.30 AM

Step 6: Update DNS Records

You aren’t quite done with the subdomain setup yet. In this next step you will be prompted with DNS records that you’ll have to add to your DNS registrar.

Screen Shot 2021-04-08 at 9.34.15 AM

If using a subdomain (like ssapi) you likely do not need to set your CNAME record in DNS. Do not set a CNAME pointing towards your primary domain (@) or www. This will cause your site to go down.

Here are what your DNS settings will look like (note the values/IP addresses may be different for you):

godaddy-dns-setup-final

In this example above, once I’m done I should have:

  • 4 A record entries in GoDaddy with host of “ssapi”
  • 4 AAAA record entries in GoDaddy with host of “ssapi”

No CNAME record added which is normal and expected.

Step 7: Verifying Your Domain DNS

After you’ve entered your DNS entries from the previous step into your DNS settings click “Done” as shown in the previous step. You’ll then be taken to the screen shown below where Google is verifying your DNS records and creating an SSL certificate for your URL.

domain-verifying

This could take an hour so don’t wait around. Come back to this screen in a few hours.

Step 8: Domain Confirmation

If your DNS was confirmed then you’ll see the screen below for the domain that you created.

For example “ecollect.getelevar.com” is a subdomain that is setup and working (note the Google-managed, auto-renewing SSL).

domain-listings

However if there was an error in verifying your subdomain then you’ll get the yellow warning flag as shown above with sstagging.getelevar.com. If this is the case for you then double check your DNS settings were set up accurately.

Step 9: Update Server Side Container Admin Settings

Once you’ve completed the DNS setup then head back to your server side container > admin and update the URL:

Screen Shot 2021-04-08 at 9.38.09 AM

Then put your server side container into preview mode:

Screen Shot 2021-04-08 at 9.38.53 AM

If everything works then you should see a screen like this:

Screen Shot 2021-04-08 at 9.39.24 AM

That’s it! You have successfully created your server side container and connected it to your own custom URL.

Configure Sources

Prior to configuring source and destinations in your Elevar dashboard, you will need to complete the previous steps in their entirety. You won’t be able to proceed without completing them.

You will own your server-side container and Google Cloud account. Elevar will not have access to either of these.

Go to your Elevar Dashboard > Server-Side Settings and select GTM as your preferred server-side option.

Once completed then you’ll be prompted to enter your server side URL in your settings:

Screen Shot 2021-12-01 at 12.14.32 PMConfigure Sources

Sources provide the data that your server-side destinations require (e.g. Facebook Conversion API).

Currently, Elevar supports the following sources of data:

Data Layer Listener

If you have our Data Layer live on your website then you may know that the Data Layer translates behavior (i.e. product views, add to cart actions) into a data structure that tags in GTM can utilize.

Elevar’s Data Layer Listener also leverages this to route data in a 1st party context from your primary Shopify domain (i.e. yourdomain.com) to your GTM server-side container (i.e. ssap.yourdomain.com). This is a powerful way to capture data that is not available via webhooks.

Your steps here are:

  1. Download our pre-built container & import into your server-side container
  2. Install data layer listener on checkout
  3. Install data layer listener on your theme (this will create the snippet below and inject into theme.liquid and checkout.liquid for Plus stores)

Screen Shot 2021-12-01 at 1.29.12 PM

If you have development team that uses Github please be sure this change is checked into version control.

Shopify Notifications (aka “Webhook)

When configuring this data source, we will install a webhook on your store that listens for specific events like order creation, refund creation, etc. For example, when an order is placed, Shopify will essentially say “Hey Elevar, I have a new order for this store” and we fetch the order parameters we need for your integrations.

This moves all order processing out of the browser to maximize accuracy.

One big benefit to Shopify Notifications data sources is that it allows access to all of your orders not just “Online Store” orders. So you can send orders from any channel to your chosen destinations. This can help replace any offline conversion integrations you might be supporting.

Your steps to complete this setup are:

  1. Download our pre-built container & import into your server-side container
  2. Install webhook via Elevar configuration

We do need to call out one other dependency here. Our data layer has a feature called “Order Notes” that does the dirty work of storing various attribution data (like UTMs, fbclid, gclid, etc) that improves the accuracy of your server-side destinations.

Screen Shot 2021-11-04 at 6.04.07 AM

You’ll want to leave this enabled in your Data Layer event settings. Without this then your destinations will lack data used for attribution.

You aren’t limited to just the pre-built tag destinations that Elevar creates. Since we have a generic server side Client that is listening for Shopify transactions, you can associate multiple tags to the `shopify_notification` trigger that we create.

This gives technical GTM teams the ability to create as many server-side tracking tags using Shopify webhooks as they’d like (without being fully reliant on Elevar to create these templates)

Webhook Configuration Troubleshooting

In each of our steps we offer the ability to test your server-side endpoint works. If you come across an unsuccessful test like this:

Screen Shot 2021-12-01 at 12.32.19 PM

Then double check the following:

  1. The server side container URL configured in your Settings is correct
  2. You’ve completed the DNS setup inside Google Cloud (this could take up to a few hours to propagate)
  3. You’ve configured your custom URL inside your server side container

Configure Destinations

Server-Side Destinations are where you want to send your data. These are typically synonymous with your marketing pixel integrations you’re used to like Facebook, Google Ads, Google Analytics, TikTok, etc.

Our current server-side destinations supported include channels like Facebook, TikTok, Snapchat, Criteo, Google Analytics, and more.

Each pre-built container provided in your dashboard provides you full control over the most detailed aspects between your store and the destination.

One important change to note is how transactions are handled.

For Google Analytics:

Historically you may have used a GA Event – Purchase tag in your GTM web container.

If you decide to configure our server-side tracking for GA then you’ll need to disable this tag in your web container in lieu of the tag setup in your GTM server-side container.

Interesting in digging into channel specific guides?

Find the channel you’re looking for in our Tracking Integrations catalog.