Best Practices for Using HubSpot and Google Analytics Together/
November 1, 2016
HubSpot users love the automated marketing and sales platform for many reasons, including the ability to easily create landing pages, drive inbound campaigns, and connect directly with their customers. In addition, HubSpot offers some reporting options to help measure and track how your campaigns perform, how many leads you have driven, and which channels are driving the most traffic.
The tool can be used in a variety of ways and with varying amounts of time investment, and like most tools, we have found that pairing HubSpot with Google Analytics can enhance both tools. Google Analytics will not replace HubSpot, but rather will help you measure its impact on your site’s goals and help you to more clearly evaluate its efficacy in addition to your other traffic drivers.
Below, I’ll discuss a few best practices and some more advanced ways to integrate HubSpot and Google Analytics.
HubSpot Website Pages
One of the great features of HubSpot is the ability to create templated websites or branded landing pages for your website. Often, these special HubSpot pages will live on a subdomain or even an entirely different domain, and that means that Google Analytics tracking may not be exactly straightforward. Users may interact with your landing pages or they may interact with your website or they may interact with both. Proper Google Analytics implementation will be necessary to make sure these users are tracked consistently between the two.
Subdomain vs Subdirectory vs Different Domain?
The different subscription levels of HubSpot come with different options, so make sure you understand what your subscription level will include. If you have the choice, subdirectories have the least amount of extra setup required to work properly with Google Analytics. If you’re still planning your implementation, definitely choose this option for your blog if it’s an option!
Often, the custom landing pages will live on a separate subdomain (ex. info.lunametrics.com). This is a little more complicated than subdirectories, so you will need to verify certain settings. Completely separate domains (ex. lunadownloads.com) will make tracking the two sites together inside of Google Analytics very complicated, so I wouldn’t recommend this without understanding all of the implications related to your analytics.
Basic Google Analytics Tracking
The first step is getting Google Analytics tracking on all of your site pages, regardless of whether they live in your CMS or are being loaded from HubSpot.
HubSpot has an easy setting to help with placing Google Analytics tracking code on page. Basic pageviews can be tracked by filling in your Google Analytics tracking ID into the settings. This is the easiest option, but perhaps not the most flexible.
Adding Google Tag Manager
Now that we’ve added Google Tag Manager, it’s pretty easy to add a Google Analytics tag across all of your pages. We won’t go into all of the details here, but a few things to check.
- Make sure you only have Google Analytics tracking on your pages once. If you have filled in your GA tracking ID in the HubSpot settings, then do not also fire GA through Google Tag Manager.
- If you are using the subdomains option, make sure you follow the steps to getting subdomain tracking working properly. This may involve updating the cookie domain settings in your Pageview tag.
- If you have completely separate domains, you’ll need to tackle cross-domain tracking, but remember this only works if users click between the two websites.
Next Level Google Analytics Tracking
HubSpot landing pages are rich with information. Call-to-actions and forms are valuable drivers to get those leads, but they’re also opportunities to supplement your Google Analytics information.
Ok, maybe let’s not go too crazy, but let’s see how many clicks those big download buttons get, and let’s capture the information that someone fills into a form and save that information into Google Analytics.
All of this is possible with Google Tag Manager on your page, and we have plenty of tutorials and recipes to help you get started!
Emails From HubSpot
When you send out emails and drive traffic to your HubSpot pages, whether you’re using HubSpot’s automated platform, a tool like MailChimp, or some other email platform, these emails absolutely need to be tagged with UTM parameters. This is information that YOU know, what email did you send, what was the campaign, etc. We tack on some extra text to the end of the URL to help us take credit for any traffic that is driven from that particular link.
Emails that come from HubSpot can be automatically tagged with UTM parameters, following this email tracking guide from HubSpot.
In fact, HubSpot has a pretty handy option here that gives you the choice when you’d like to add URL parameters. You definitely want to add tracking, and there’s a great option that will let you add parameters unless the links are already tagged.
For emails that you’ll send out via other platforms, you’ll need to manually created tagged links to make sure they’re properly be tagged. HubSpot has a guide for that too, and it’s easy to create a link to your site with the appropriate parameters, or tracking URLs as HubSpot refers to them.
Custom Information In/Out of HubSpot
In addition to collecting information about how our HubSpot emails and landing pages are performing, we can also pass information back and forth that will give us the greatest amount of flexibility in the long run for connecting our different platforms. This is the advanced stuff.
We’ve written about the need for a common key before, a unique identifier that we can use that exists in two different systems. We’ve talked about it with SalesForce and Marketo. The same concept applies here. We’ll be pushing the Google Analytics client ID into both Google Analytics and HubSpot, though you can also go the other way and push the HubSpot Visitor ID into both systems.
Custom Properties allow storing information per contact or per company. We’ll make use of per-contact properties in our GA integration. HubSpot doesn’t use these properties internally, but keeps them with the contact record. A Custom Property could be used to store the Google Analytics Client ID so that we can later combine the client record in HubSpot and Google Analytics. The Google Analytics Client ID is, itself, an opaque identifier for each device which has accessed your site and does not itself contain any information about the device or visitor.
When using HubSpot Forms, a hidden field with the name of the custom HubSpot Property used to contain the Client ID must also be placed in the form. Before submitting the form to HubSpot, the Client ID must be extracted from Google Analytics and placed into the hidden form field manually. The following snippet of code is an example of how this may be accomplished (using jQuery).
var clientId = ga.getAll().get('clientId');
Getting the Client ID into Google Analytics
How to Combine the Data
Once the Client ID is stored, there is a link between the client record in HubSpot and in Google Analytics that we can use in many powerful ways. We are now able to connect specific web visitors on our site with their HubSpot profiles, and with some data manipulation begin to derive better insights.
To bring extra metadata into Google Analytics, we can now use the data import feature to export data from HubSpot and import the data into Google Analytics, keying off of the GA Client ID Custom Dimension we created.
In addition, the Client ID stored in HubSpot, you can begin to take advantage of the Measurement Protocol, passing hits to Google Analytics that occur offline. Purchases, conversions, or even activities like phone calls can be sent to Google Analytics and, because you now have the ability to pass the correct Client ID with the hit, you’ll connect to that particular user’s previous and future web history via the API or, for Analytics 360 customers, BigQuery.
As you’re setting up Google Analytics and HubSpot, remember to start with the basics. Make sure pageview tracking is implemented and working correctly. Follow best practices for tracking emails and other traffic drivers. And finally, consider more advanced integrations. With HubSpot and Google in lockstep, you will find boundless ideas of what can be done with your data, and how these two tools together can improve your marketing and prove your return on investment.
Jon will be speaking at the upcoming Inbound 2016 conference, held this year in Boston from November 8-11. Come and listen to his session, titled: “Go Beyond Hit Counting – Making Analytics-Informed Marketing Decisions.”