How do I connect Klipfolio and Google Analytics?

You can set up a connection between Klipfolio and Google Analytics to show your website metrics on a dashboard. Follow the steps in this article to learn how to set up a connection between Klipfolio and Google Analytics and create a data source either by using pre-built Klips and dashboards or by building your own data source from scratch.

What is Klipfolio?

Klipfolio integrates with many cloud services and tools to create meaningful data visualizations.

How do I get started with Google Analytics?

You have the following options for visualizing your data on a dashboard in Klipfolio:

Try the Klip Gallery Try Pre-Built Dashboards Use the Connector Gallery
The Klip Gallery allows you to track your key metrics using pre-built Klips for some of the most popular services and data sources. The pre-built Google Analytics Dashboards allow you to quickly share a whole dashboard of your key Google Analytics metrics. The Connector Gallery helps you get your data fast with pre-built queries. Use this article as a guide to build your own Google Analytics data source.

Authenticate with Google Analytics

As you see from your options above, there are many different ways you can choose to connect to Google Analytics in Klipfolio. No matter which route you take, the first thing you will be asked to do is authenticate and create a handshake connection between your Klipfolio and Google Analytics accounts.

  1. Click Connect new account.
  2. Enter your Google Analytics login credentials.
  3. Click Next Step.
    Note: You now have an OAuth Token for your Connected Account. Manage your tokens in the Account section under Connected Accounts.

Find your Google Analytics Profile ID

If you are connecting to Google Analytics using one of the Connector Gallery's pre-built Google Analytics queries, you will need to enter your chosen website's Profile ID into a specific spot in the query.

To find your Profile ID in Google Analytics,

  1. Sign in to your Google Analytics account.
  2. On your account home page, select a website that you want to monitor.
  3. In the Reporting interface, copy the numerical ID after the letter 'p' in the URL. Important: Do not include the letter 'p'. 

  4. Paste your Profile ID into the query in Klipfolio.

  5. Click Get Resource.

You can use the data returned to build your own Google Analytics Klips and dashboards.

Advanced: Build a data source yourself

Klipfolio connects to hundreds of services in the cloud that have a REST API. If you take the time to learn how to get data into Klipfolio using APIs, your possibilities are endless. Here's a quick and simple overview video on APIs and Klipfolio:

  Klipfolio API's 101

If you need any support while working with APIs, enlist a data analyst or developer to help you.

If you want to edit a Google Analytics data source that you already created, check out How to edit or reconfigure a data source, and get step-by-step instructions.

To build a Google Analytics data source from scratch, refer to the quick reference table below for links and key information.

You have the following options when building your query:

  • Choose Simple Mode to build your query using drop-down menus.
  • Choose Advanced Mode to build your query from scratch
  • To make additional adjustments to your Simple Mode query, Import the query to Advanced Mode.

Google Analytics quick reference table

API Documentation Google Analytics API Docs
Account For API access, ensure that you have Read and Analyze permissions.
Simple Mode Simple Mode provides an interface for writing a RESTful URL that retrieves data from your Google Analytics account. (See below for more detailed instructions)
Advanced Mode Advanced mode lets you write a RESTful URL by hand or using the Google Analytics Graph API Query Explorer. This method is intended for advanced users with knowledge of Google Analytics API. (See below for more detailed instructions).
Video: Use Google Analytics as a data source
Sample Query This is an example of a query URL you may see when using Advanced Mode.

https://www.googleapis.com/analytics/v3/data/ga?ids=ga:Your-Profile-ID&metrics=ga%3Ausers&start-date=2012-01-14&end-date=2012-01-21
For Dimensions / Metrics that
require additional input
Some Dimensions and Metrics require additional input. To resolve this issue, follow these steps:
1. Switch from Simple Mode to Advanced Mode.
2. Change the value (n) to 1
For example: ga:customVarName(n)
becomes: ga:customVarName1

Write the query and enter it in Klipfolio (Simple Mode)

In the Google Analytics connector in Klipfolio, you can use Simple Mode to connect your data using the drop-down menus provided. This method enables you to specify which dimensions, metrics, and the time period you want to get in your data source from Google Analytics.
Note: If you want to retrieve data that includes segments and/or filters, you should use Advanced Mode.

In the New Data Source page for Google Analytics,

  1. Select Simple Mode from the drop-down menu.
  2. Optional: Select one or more Dimensions from the menu.
  3. Select one or more Metrics from the menu. Important! You are allowed a limit of 10 metrics per data request.
  4. Select an appropriate Time Period from the menu.
  5. Click Get Data.
  6. Save and name your data source.

Additional Information

Use the Google Analytics API to write a query (Advanced Mode)

You can build a query using the Google Analytics Graph API Query Explorer, and bring that query into Klipfolio. Or get started in Simple Mode, and import your query to Advanced Mode.

Here are some example queries to get you started:

For organic search landing page performance

https://www.googleapis.com/analytics/v3/data/ga?ids=ga:<Your-Profile-Id>&metrics=ga:users,ga:sessions,ga:bounceRate,ga:goalCompletionsAll,ga:avgTimeOnPage&dimensions=ga:hostname,ga:landingPagePath,ga:channelGrouping&filters=ga%3AchannelGrouping%3D%3DOrganic%20Search%3Bga%3Asessions%3E20&start-date={date.add(-30).format()}&end-date={date.yesterday}&max-results=10000

For your website performance data

https://www.googleapis.com/analytics/v3/data/ga?ids=ga:<Your-Profile-Id>&start-date={date.add(-730).format()}&end-date=today&metrics=ga:users,ga:newUsers,ga:percentNewSessions,ga:sessions,ga:bounces,ga:bounceRate,ga:sessionDuration,ga:avgSessionDuration,ga:pageviews,ga:pageviewsPerSession&dimensions=ga:date&sort=-ga:date

Important! You are allowed a limit of 10 metrics per data request.

How to convert a static date range in your query to a dynamic one

Many Klips that use Google Analytics data need a rolling date range that is dynamic (for example, past 30 days). In this section we're going to change a static query from a fixed date range to a dynamic one.

  1. Find start-date= in your Query URI.
  2. Delete the date that appears right after it. Note: Only delete the data that appears in yyyy-mm-dd format.
  3. Replace it with the following: {date.last30Days}
  4. Find end-date=and delete the date that follows it.
  5. Replace it with the following: {date.today}
  6. Click the Get Data button.
  7. Save and name your data source.

If your query returned an error, make sure it looks like this:

https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3A{ProfileID}&metrics=ga%3Avisitors&start-date={date.last30Days}&end-date={date.today}

Common date range expressions:

AdWords

You can also link your Google Analytics account to your Adwords account in order to analyze web site traffic or sales driven by Adwords. Some useful metrics include impressions, click through rate, and ad costs. For more information, see Link Google Analytics and Adwords.

Related Links