After launching a massive amount of new data through our Data Export API, our developers gave us a lot of great feedback back and support. Thanks! Now we want to show you how to master this data to make better business decisions, starting with the unique visitors metric.
In this blog post, we ask Analytics team members to give us their favorite ways to request and use unique visitor data. Next, we translate that into an API query along with screen shots of how the data looks. Finally, we give you a deep link to the query explorer tool so you can make that same API request with your own data right now. Let's Go!
(Note: You can do most of these queries using Custom Reports through the Google Analytics web interface.)
Query example #1: Measuring Total Unique Visitors
Before we start using suggested queries, let's lay the ground work with a very simple query for unique visitors.
https://www.google.com/analytics/feeds/data
?ids=<tableId>
&metrics=ga:visitors
&start-date=2011-01-01
&end-date=2011-01-31
Awesome Hetal! All we need to do is add the ga:week time dimension to get weekly unique visitors or as we say at Google, “7-day actives.”
See your own data in the Query Explorer
*In this query segment, a visitor that visits the site 5 times will only have his/her 4th and 5th sessions included, but not the 1st to 3rd sessions (More documentation on ga:visitCount).
See your own data in the Query Explorer
Query Example #7: Visitor Based Conversion Rate
Avinash Kaushik is the Analytics Evangelist at Google. He has a best selling book about web analytics, and a great use case. Google Analytics uses session-based metrics for most of its performance calculations. For example, conversion rate = conversions / visits. Most unique visitors will not convert every time they come to your site. So sometimes it might be better to calculate conversion rate as conversions / visitors.
https://www.google.com/analytics/feeds/data
?ids=<tableId>
&dimensions=ga:source
&metrics=ga:visitors,ga:goalCompletionsAll
&filters=ga:medium==organic
&sort=-ga:visitors
&start-date=2011-01-01
&end-date=2011-01-15
&max-results=5
Here we look at the top organic search engines, but now let’s request the goalCompletionsAll metric. Of course, you can easily use any of the 20 individual goals, the number of transactions or events, or the total revenue for this calculation if you prefer.
See your own data in the Query Explorer
By now you should see you can get unique visitors for almost any dimension in Google Analytics!
Query Example #8: Visitor Loyalty Per Content Section
Patricia Boswell is the lead of our documentation efforts for Google Analytics. Measuring performance of the content that is produced is very important to her. She likes to use the unique visitors metric to report the number of unique visitors who visit a specific content section of the site. She then compares that to the number of unique pageviews to get a sense of how frequently unique visitors are viewing specific set of pages.
https://www.google.com/analytics/feeds/data
?ids=<tableId>
&metrics=ga:visitors,ga:uniquePageviews
&filters=ga:pagePath=~product
&start-date=2011-01-01
&end-date=2011-01-15
Here we apply a filter which uses a regular expression to match any pages that have the word “product” in their URL. Using the advanced segment returns all sessions, which had at least one pageview that included the word “product.” Google Analytics then returns the number of unique visitors for those sessions.
We see here that the pageviews per visitor ratio for the support section is 2.85 (= 342/120).
So while more unique visitors saw the product pages, unique visitors were more engaged on the support section. This might influence your content development strategy by considering cross selling products and services within the content section vs the product section.
See your own data in the Query Explorer
In this blog post, we ask Analytics team members to give us their favorite ways to request and use unique visitor data. Next, we translate that into an API query along with screen shots of how the data looks. Finally, we give you a deep link to the query explorer tool so you can make that same API request with your own data right now. Let's Go!
(Note: You can do most of these queries using Custom Reports through the Google Analytics web interface.)
Query example #1: Measuring Total Unique Visitors
Before we start using suggested queries, let's lay the ground work with a very simple query for unique visitors.
https://www.google.com/analytics/feeds/data
?ids=<tableId>
&metrics=ga:visitors
&start-date=2011-01-01
&end-date=2011-01-31
This query retrieves the total unique visitors to our site for the month of January.
You can click this link to execute this query with your own data. Simple!
Query example #2: Monthly, Weekly, and Daily Unique Visitors
Ok, the query above was easy. So maybe we want to know how many of these users are active users. Hetal Thakkar, the engineer who implemented the processing logic for this metric, says it’s easy with the following query:
https://www.google.com/analytics/feeds/data
?ids=<tableId>
&dimensions=ga:week
&metrics=ga:visitors
&start-date=2011-01-02
&end-date=2011-02-12
Awesome Hetal! All we need to do is add the ga:week time dimension to get weekly unique visitors or as we say at Google, “7-day actives.”
In fact, you can measure active users for other time periods by using ga:year, ga:month, ga:day or even ga:hour instead. This gives you the measure of what advertisers call “reach.”
Query example #3: Hourly Unique Visitors by City
Recently an agency wanted to understand how many unique visitors would visit their site after airing a TV commercial. They exported hourly unique visitors by region, and ran some additional statistical analysis.
https://www.google.com/analytics/feeds/data
?ids=<tableId>
&dimensions=ga:region,ga:city,ga:hour
&metrics=ga:visitors
&filters=ga:region==California
&sort=ga:region,ga:city,ga:hour
&start-date=2011-01-01
&end-date=2011-01-01
&max-results=50
Here we use both the ga:region and ga:city dimensions to get the number of unique visitor by city. Even though we use a filter to only get data from California, we add the region dimension to make the report easier to read. We then use ga:hour to get hourly unique visitors by city. Since the TV ads were only running in California, we use the filters parameter to filter by region. We also limit the date range to the day the ad ran.
Here are a few results from Alameda, California.
Now you are ready to analyze the online impact of your offline campaigns, such as radio and TV.
You can apply the unique visitors metric to almost any existing report to get amazing new insights.
Query Example #4: Mobile Unique Visitors By Country
Ivanna Kartarahardja is a software engineer on the Google Analytics API team. She did a lot of the coding to make this data available through the API. Thank you Ivanna!
One of her favorite reports is looking at mobile unique visitors by country.
https://www.google.com/analytics/feeds/data
?ids=<tableId>
&dimensions=ga:country
&metrics=ga:visitors
&segment=dynamic::ga:isMobile==Yes
&filters=ga:subContinent==Western%20Europe
&sort=ga:country
&start-date=2011-01-01
&end-date=2011-01-15
&max-results=50
In this query we use a dynamic advanced segment to only query users who have come from a mobile device. We also added a filter to only look for mobile traffic from Western Europe.
See your own data in the Query Explorer
This report is also very useful if you are trying to measure the performance of your mobile application using either our Google Analytics Andriod SDK or iOS SDK. Metrics like this help you decide which languages and regions to invest in.
Query Example #5: nique Visitors by Mobile Device
Jeetendra Soneja is the Lead Engineer for the Google Analytics APIs. His favorite report is to look at mobile unique visitors by platform. He thinks this is a great way to identify which platforms to invest resources into.
https://www.google.com/analytics/feeds/data
?ids=<tableId>
&dimensions=ga:operatingSystem
&metrics=ga:visitors
&segment=dynamic::ga:isMobile==Yes
&sort=-ga:visitors
&start-date=2011-01-01
&end-date=2011-01-15
&max-results=50
This report is also very useful if you are trying to measure the performance of your mobile application using either our Google Analytics Andriod SDK or iOS SDK. Metrics like this help you decide which languages and regions to invest in.
Query Example #5: nique Visitors by Mobile Device
Jeetendra Soneja is the Lead Engineer for the Google Analytics APIs. His favorite report is to look at mobile unique visitors by platform. He thinks this is a great way to identify which platforms to invest resources into.
?ids=<tableId>
&dimensions=ga:operatingSystem
&metrics=ga:visitors
&segment=dynamic::ga:isMobile==Yes
&sort=-ga:visitors
&start-date=2011-01-01
&end-date=2011-01-15
&max-results=50
Notice how in the last two queries we’re using a dynamic advanced segment to only look at a specific segment of all users (dynamic::ga:isMobile==Yes). We can then apply any of our useful dimensions to gain more insight about those specific users.
Query Example #6: Measuring Site Loyalty
Sagnik Nandy oversees data processing for Google Analytics. You met him in Web Analytics TV #16, and he always has clever tricks on how to build complex queries. He likes using visit count to measure site loyalty.
https://www.google.com/analytics/feeds/data
?ids=<tableId>
&metrics=ga:visitors
&segment=dynamic::ga:visitCount=~^[4-9]
&start-date=2011-01-01
&end-date=2011-01-31
&max-results=50
Here we will get back the number of visitors that have visited the sites between 4 and 9 times resulting in a custom loyalty report. Since ga:visitCount* is a dimension, which is a string, we use a regular expression to match all values between 4 and 9.
See your own data in the Query Explorer
Query Example #7: Visitor Based Conversion Rate
Avinash Kaushik is the Analytics Evangelist at Google. He has a best selling book about web analytics, and a great use case. Google Analytics uses session-based metrics for most of its performance calculations. For example, conversion rate = conversions / visits. Most unique visitors will not convert every time they come to your site. So sometimes it might be better to calculate conversion rate as conversions / visitors.
https://www.google.com/analytics/feeds/data
?ids=<tableId>
&dimensions=ga:source
&metrics=ga:visitors,ga:goalCompletionsAll
&filters=ga:medium==organic
&sort=-ga:visitors
&start-date=2011-01-01
&end-date=2011-01-15
&max-results=5
Here we look at the top organic search engines, but now let’s request the goalCompletionsAll metric. Of course, you can easily use any of the 20 individual goals, the number of transactions or events, or the total revenue for this calculation if you prefer.
See your own data in the Query Explorer
By now you should see you can get unique visitors for almost any dimension in Google Analytics!
Query Example #8: Visitor Loyalty Per Content Section
Patricia Boswell is the lead of our documentation efforts for Google Analytics. Measuring performance of the content that is produced is very important to her. She likes to use the unique visitors metric to report the number of unique visitors who visit a specific content section of the site. She then compares that to the number of unique pageviews to get a sense of how frequently unique visitors are viewing specific set of pages.
https://www.google.com/analytics/feeds/data
?ids=<tableId>
&metrics=ga:visitors,ga:uniquePageviews
&filters=ga:pagePath=~product
&start-date=2011-01-01
&end-date=2011-01-15
Here we apply a filter which uses a regular expression to match any pages that have the word “product” in their URL. Using the advanced segment returns all sessions, which had at least one pageview that included the word “product.” Google Analytics then returns the number of unique visitors for those sessions.
So if we divide unique pageviews (276) by unique visitors (249), we get 1.10, which is the frequency that unique visitors visit a product page.
Let’s compare this to frequency of unique visitors visiting our support section. All we do is change the query to filter the ga:pagePath dimension on the word “support.”
&filters=ga:pagePath=~support
And we get:
Let’s compare this to frequency of unique visitors visiting our support section. All we do is change the query to filter the ga:pagePath dimension on the word “support.”
&filters=ga:pagePath=~support
We see here that the pageviews per visitor ratio for the support section is 2.85 (= 342/120).
So while more unique visitors saw the product pages, unique visitors were more engaged on the support section. This might influence your content development strategy by considering cross selling products and services within the content section vs the product section.
See your own data in the Query Explorer
Your Turn!
With the addition of unique visitors to the API, you can gain even more insight about your customers. We encourage you to democratize your data by sharing this article with colleagues and friends. Also we’d love to hear your best use cases for using unique visitors in the comments section below. Thanks!