Integrating with Google Analytics

Follow

 If you're reading this in our web widget, consider expanding the article for a better reading experience. 

You can integrate your landing pages with Google Analytics by using one of two methods.

1) Integrating across a domain using Script Manager or

2) Integrating your landing pages manually.

If you're looking to integrate Popups or Stickybars with event tracking in Google Analytics, head on over to Integrating Popups and Stickybars with Event Tracking in Google Analytics.

What you will need

  • A Google Analytics Account
  • An Unbounce Account
  • A working domain or subdomain

Estimated time to complete: 7-15 minutes.

Pro-tip

Before integrating with Google Analytics, please ensure that any Personally Identifiable Information (PII) is stripped out of the URL that Unbounce passes to Google Analytics, as per Google Policy.

Before you start, we recommend enabling bot filtering when using Google Analytics with Unbounce landing pages. Follow the steps in the screenshot below:GoogleAnalyticsEnableBotFiltering.png


Integrating Landing Pages with Google Analytics (through Script Manager)

Step One: Retrieve Your UA Tracking ID from Google Analytics

Our current Google Analytics integration will only work with a UA property, and not the new G4 property. When creating a Google Analytics account, a G4 Property is created by default, so please follow the instructions to create a UA property. Without a UA property, you won't be able to find the UA code. Further instructions can be found here: Setting up a UA Property.

Step Two: Enter your Website Tracking ID in Script Manager:

  1. Within the Unbounce App, select the Settings tab on the left-side menu bar.
  2. Select Script Manager from the list of Settings options.
  3. From Script Manager, click the button at the top-right to Add a Script, and select Google Analytics from the drop-down menu.
    addascript.png
  4. Enter your UA Tracking ID (provided by Google Analytics), then click Add Script Details.
  5. A new page will appear with two panels:
    • Script Details, and
    • Script Usage.
  6. In the Script Usage field, select which subdomain(s) you'd like to apply the Google Tracking Script to:addascript2.png
  7. Click Save and Publish Script.

You've now integrated Google Analytics with the selected subdomain and its connected pages!


Integrating Landing Pages with Google Analytics (Manually)

As an alternative to the Script Manager option, it's possible to follow a manual method of integrating with Google Analytics on individual landing pages. This comes in handy with use cases that require customization to the Google Analytics script. Some examples are:

  • Display feature tracking
  • Custom dimensions
  • Opting out of automated tracking
  • Anonymize specific IP addresses in Google Analytics

To embed Google Analytics tracking on individual landing pages, you need:

  • A Google Analytics Account
  • An Unbounce Account 
  1. Select and copy your tracking code from your Google Analytics account. This is found under Admin > Select Account > Select Property >Tracking Info > Tracking Code. For detailed instructions, check out Google's Guide on how to get your tracking code.
  2. Return to Unbounce and paste the tracking code into your landing page's Javascript library Select 'Head' for placement.
  3. If using a Form Confirmation Dialog, paste the tracking code into your confirmation dialog as well and select 'Head' for placement.
  4. Save and republish your page.

Google Analytics will track metrics for your landing pages immediately, but these will not display in reports for about 24 hours.

Pro-tip

Active visitors on your page will be immediately visible in your 'Real-Time' reports. Full visitor data populates to the rest of the reports about 24 hours later. For this reason, there is always an approximate 24 hours lag between stats collected in Unbounce and stats collected in GA.

Creating a Google Analytics Conversion Goal Using Regular Expressions

Adding Goals in Google Analytics lets you track when you're hitting target objectives. If you're using the Unbounce Form Confirmation Dialog and would like to track form submissions as a Goal in Google Analytics, you can achieve that with regular expressions (regex).

A regular expression allows Google Analytics to track each variant on your landing page without you having to create a new goal for each variant. If you’re using the Unbounce Form Confirmation Dialog, you can directly track form submissions as Conversion Goals in Google Analytics. 

Head over to your Google Analytics account and follow these steps:

  1. In Google Analytics, navigate to the Admin tab, then open Goals.
  2. Create a new Goal.
  3. Under the Goal description tab, choose a Name for your Goal & select Destination (under Goal type),
  4. Under the Goal details tab, choose Regular Expression from the dropdown menu: “regex-setup”
  5. Next, we’ll add type-in a regular expression, depending on which domain or file path you’d like to track your goals under. Choose from the following regular expressions:

a) /.+-form_confirmation\.html

This regex formula will set a destination goal for all pages using a form confirmation dialog; it will count all visits to the form_confirmation.html URL on any variant or file path.

For example, to track submissions on "my.landingpage.io", as well as "my.landingpage.io/about-page/", my regular expression would be "/.+-form_confirmation\.html.”

b) /landing page path/.+-form_confirmation\.html

To narrow down the goal to an individual page with a specific file path/URL, specify a more defined variant before the regular expression. This regex allows you to specify any variant on a particular page path.

For example, if my landing page lives on "my.landingpage.io/landingpage", my regular expression would be "/landingpage/.+-form_confirmation\.html"

c) ^/.+-form_confirmation\.html

To track a goal for your landing page that lives at your root domain only (no additional page paths), use this regular expression.

For example, if my landing page lives at "my.landingpage.io," my regular expression would be "^/.+-form_confirmation\.html.”

Here is an example of option b:

standardsmall.png

These regular expressions work best with tracking goals when using the Unbounce Form Confirmation Dialog and our native Google Analytics integration. 

Track Goals without a Form Confirmation Dialog

Suppose you’re hoping to track conversions in Google Analytics without the Unbounce Form Confirmation Dialog. In that case, you can either:

1) Create a Destination goal with the Confirmation Page’s URL: This will treat a pageview as a conversion. In other words, when your page visitors land on an external thank-you page or confirmation page, the Goal is captured in Google Analytics.

Google Analytics needs to be installed on the external thank-you or confirmation page too. To set this up, paste in the thank-you/confirmation page URL and as your Destination URL. Google’s documentation has more insight into destination goal tracking: Goal configuration options.

2) Track Form Submission Events using Event Tracking. This is a bit more complex but doable! The following section will go into more detail about events, and insight into setting up form submissions events as Goals.

Further information regarding Goals & Google Analytics:


Customizing Google Analytics Event Tracking

Follow the steps below to customize Google Analytics event tracking.

Integrating your pages with Google Analytics via Script Manager will automatically send event tracking information for your page’s action items directly into Google Analytics (such as button clicks, text link clicks, etc.).

To start, take a read of Google’s documentation explaining the Anatomy of Events.

If you manually installed Google Analytics onto your pages, you will need to set up manual event tracking before you can customize this data in Unbounce. See Setting Up Event Tracking in Google Analytics for Google's handy instructions on how to do this.

To explain Event Tracking, let’s try out an example! Below is an example of how to set up event tracking for an Unbounce lead generation form and social sharing links on this page:

form-example-for-event-tracking-in-google-analytics

    1. To set up custom event tracking for these elements, start by copying the ID of each element you’d like to track within the Properties panel of the builder:
      “copying-element-id”
    2. Next, click JavaScripts within the page builder to open up the JavaScript widget.
    3. Copy & paste the following script into the blank field within the JavaScript widget:
    4. Update the following text within the code:

      • #lp-pom-ID-OF-ELEMENT or .lp-pom-CLASS-OF-ELEMENT: this will be the element ID or Class for which you’d like to track a custom event. IDs are more unique, so it may be best to use them for buttons or text links. Here is a reference for some differences between Class and ID Selectors.

      • My Event Category: the Category parameter applies to all objects you’d like to group & analyze together. For example, 'Forms,' 'Videos,' 'Outbound links', are examples of popular Categories.

      • My Event Action: the Action parameter explains what occurs once users interact with this element. For example, 'Click,' 'Download,' 'Submit' are examples of popular Categories.

      • My Event Label: the Label parameter provides additional information to the Action; your Label value can be anything of your choice. Some examples are 'Spring Campaign,' 'Sign-up Form,' or 'Request an E-Book,' etc.

    5. Using the above landing page as an example, here are the updated Event Categories, Actions & Labels:
      “event-category-action-labels-example”
      Line 2 of this script uses a Class selector to reference the built-in Unbounce form (.lp-pom-form). Lines 3-5 uses ID selectors for the specific buttons (#lp-pom-text-349).
    6. Select Before Body End Tag from the Placement drop-down menu.
    7. Click Done to save the script and repeat this for every page desired. Be sure to Save & Republish/Publish your landing page.

You’re all set! To view these events in Google Analytics Reports, navigate to Behaviour > Events > Reports Overview.

Track Form Submission Events as Goals

Tracking form submission events as Goals requires some additional setup steps in Google Analytics. The Event, Category, and Action Labels will need to match the values set up in Unbounce exactly.

For example, if the form ID in Unbounce is '#lp-pom-form-42' and you have not yet customized your event tracking using the above scripts, '#lp-pom-form-42' is the label you'd enter while configuring the Goal in Google Analytics.

However, if you have customized the event tracking using the provided script above and (as an example) have set the label to "Form," then "Form" is the label that will need to be used in the goal configuration.

You can find your events' unique values by testing your form, viewing the data within the Realtime Reports, or after waiting 24 hours for the data to fully process, then viewing the Behaviour > Events Reports tab in Google Analytics.

Or by installing an extension such as Google Analytics Debugger and testing a submission with the developer's console open.


Analyzing Your Pages in Google Analytics

When integrating Google Analytics across your landing pages using the Script Manager, Unbounce will send the following events & info back to Google Analytics: Button Clicks, Text Link Clicks, Form Submissions, and Variant Tracking.

When analyzing variants in Google Analytics, the variant letter appends to the end of the URL. For example, if my landing page URL is my.landingpage.io, with two active variants (A & B), then variant URLs will in Google Analytics appear as follows:
my.landingpage.io/a & my.landingpage.io/b.

If I have additional file paths, the URLs in Google Analytics will be:
my.landingpage.io/about-page/a or my.landingpage.io/contact-us/b.


Next Steps

Setting up Referral Exclusion Lists & Subdomain Tracking

If you are using the same Google Analytics property to track page stats across different subdomains (for example, if visitors on 'my.landingpage.io' also visit the 'about.landingpage.io' domain), Google Analytics' system, by default, will count this as 2 pageviews on 2 separate sessions.

To remedy this, you can look into Referral Exclusions, which will prevent Google Analytics' system from tracking stats from subdomains at the start of a new session.

Once set up, the session that starts on 'my.landingpage.io' would continue even after users navigate to 'about.landingpage.io' (e.g., a different subdomain with the same root domain). This would translate to 1 session and 2 pageviews recorded for the visitor in Google Analytics, tracking the user's journey across subdomains.

To set this up, add a new view in Analytics, then follow Google Analytics' steps to set up Referral Exclusion lists. With Referral Exclusion lists, only one session will count per user.

Filters and Referral Exclusions 

In conjugation with Referral Exclusions, you can apply an advanced & custom filter to your Google Analytics view, to better analyze your different subdomains/hostnames alongside page URLs in your reports.

By default, Google Analytics only displays your page URL, and does not include the hostname. For example, reports display page URLs like ‘ /about-us,’ or ‘/contact-us,' instead of ‘about.landingpage.io/about-us,’ or ‘my.landingpage.io/contact-us.’

Advanced filters can be set up within the Admin page in Google Analytics to include both the hostname and page URLs.

Google’s guide to Viewing Full Page URL In Reports demonstrates how to use filters to append the hostname to the landing page and page URLs in your reports.

To filter data within your reports directly, you can add a Secondary Dimension for 'Hostname' while in your Analytics reports. This will break down your page insights by URLs & domains only. Do note that setting up filters within the Admin page would be a long-term solution.

Cross-Domain Tracking

Since our native integration allocates only one UA tracking code set up at a time (the UA-code cannot be modified), cross-domain tracking is currently outside our support teams’ scope.

While this can be set up by installing Google Analytics manually on your landing pages, setting up events and analyzing these customized reports requires an intermediate-level understanding of Google Analytics and Google Tag Manager. These custom reports can be error-prone since analyzing data in a property that tracks multiple domains can be tricky, making its setup something you would need to dabble with outside of Unbounce and our Support teams.

If you’d like to give this a try, here are some guides & resources to help point you in the right direction: Google’s guide to measuring activity across domains (using Google Tag Manager), and step-by-step instructions on how to set up cross-domain tracking. For questions about implementing or setting up cross-domain tracking, post them directly on Google’s Community forum.

Customizing Your Reports

Data collected from this integration is handled within your Google Analytics account. Check Google's site for information on building customized reports.