Not every SharpSpring user solely uses the site analytics provided by the application. Very often, users want Google Analytics implemented on their site along with SharpSpring tracking code. With the advent of the Landing Page Builder, those pages hosted in SharpSpring don’t have access to their Google Analytics tracking. In this article, we’ll walk through how to implement GA to your landing pages built in SharpSpring through an implementation of the Google Tag Manager. If you don’t use GTM, the steps would be the same, only you would use the code snippet generated by GA rather than GTM. For this tutorial, we’ll need:
A Google Analytics account
A Google Tag Manager account
Landing pages built in SharpSpring that we’d like to track in GA
If you already have Google Analytics and Google Tag Manager accounts configured properly for the domain of the site you’ll be using to build landing pages in SharpSpring, skip to the Adding Tracking Code to Landing Pages section.
Step 1: Log in or create a Google Analytics account. In this example, I created a new Account with the Default URL of the subdomain of the site I set up in SharpSpring that was enabled for the Landing Page Builder feature (blog.bryantobin.com). If you already have a Google Analytics account for the root domain of the subdomain you’re using for landing pages in SharpSpring, you can use the tracking code from that account but it will require configuring GA to track subdomains. This article contains more information on Tracking Subdomains in Google Analytics.
Step 2: Under Admin >> Property >> Property Settings, copy the Tracking ID. This will be used when we set up Google Tag Manager. It should look like UA-XXXXXXXX-X.
Google Tag Manager
Step 1: Log in or create a Google Tag Manager account. In this example, I created a new Account with the Container Name of the subdomain being used to create landing pages (blog.bryantobin.com). Ensure it is a Web Container type.
Step 2: Inside the Container, we’ll first create a variable for our Google Analytics tracking ID. Navigate to Container » Variables » Scroll down to User-Defined Variables and click “New”.
Step 3: Name the variable “gaProperty”. Select “Constant” for the Type. For the Value, paste the tracking ID of your Google Analytics Account (e.g. UA-12345678-9). Click “Create Variable”.
Step 4: Next, we’ll create a PageView tag to track all page views to our landing pages. Navigate to the “Tags” section and click “New”.
Step 5: Name the tag “PageView”. Select “Google Analytics” for the Product and “Universal Analytics” for the Tag Type. For Tracking ID, click the button to the right of the text input to display a list of variables. Click the “gaProperty” variable we just created. For Track Type, select “Page View”. For the Fire On section, choose “All Pages”. Click “Create Tag”.
In this example, I also created a Form Submission tag for the form on our landing page. For more information on creating additional event tags in Google Tag Manager, see Google Analytics events.
Step 6: Now that we have our Tag set up, we need to grab the tracking code to put on our landing pages. Navigate to Admin » Under Container, click “Install Google Tag Manager”. Copy the snippet of tracking code.
Adding Tracking Code to Landing Pages
Step 1: Log in to SharpSpring and navigate to the Landing Page Builder under Pages >> Landing Pages. Click the pencil of the page you want to track to open the page editor.
Step 2: On the left hand side are a number of editor options. Click the brackets option titled “Edit Code”.
The brackets should contain your Google Tag Manager Container ID (i.e. GTM-XXXXXX). Check that the value in the tracking code is the same as your Container ID in the Google Tag Manager dashboard.
Step 5: Click “Save” in the Code Editor.
Step 6: Navigate to “Page Settings” on the left hand side. Scroll down and click on “Publish” to make your changes go live.
(Note: Publishing changes can take a moment. Before testing that data is being pulled through to Google Analytics, allow 10-15 minutes.)
Congratulations! Your landing pages should now be reporting site traffic and analytics to your Google Analytics account.