Back in Web Analytics TV episode 8, Cesar Brea asked if there was a way to use Advanced Segments to get performance metrics for a list of target cities. As Cesar Brea pointed out in the post comments, because Google Analytics only returns city names (e.g. "Paris"), you need to request both the city and region names to disambiguate between cities with the same name (e.g. "Paris, Texas" vs. "Paris, California" vs. "Paris, France").
The Advanced Segment builder in Google Analytics allow you to create expressions only in the following form:
(City A OR City B) AND (Region X OR Region Y)
But what Cesar really needed was to build an Advanced Segment of the form:
(City A AND Region X) OR (City B AND Region Y)
One option is to create individual segments through the interface, export to CSV then open all the CSV files, and merge the data into a single file. Lots of work. The other option is more elegant and powerful: automate the task with the API.
(City A OR City B) AND (Region X OR Region Y)
But what Cesar really needed was to build an Advanced Segment of the form:
(City A AND Region X) OR (City B AND Region Y)
One option is to create individual segments through the interface, export to CSV then open all the CSV files, and merge the data into a single file. Lots of work. The other option is more elegant and powerful: automate the task with the API.
An Elegant Solution
So Cesar did exactly that and partnered with Newcircle Consulting to built the free Target Towns Google Analytics API solution. With Target Towns, you simply authorize the tool to access your Google Analytics account. You upload a list of regions and cities, and the tool runs a bunch of API requests for you to get performance data for your top target towns. Simple!
So Cesar did exactly that and partnered with Newcircle Consulting to built the free Target Towns Google Analytics API solution. With Target Towns, you simply authorize the tool to access your Google Analytics account. You upload a list of regions and cities, and the tool runs a bunch of API requests for you to get performance data for your top target towns. Simple!
Business Impact
What’s really interesting is how analysts are using this tool to get better insight into the geo-breakdown of their marketing campaigns.
One geo-information user is Perry Hewitt, Director of Digital Communications and Communications Services at Harvard University. One of Perry’s goals is to increase non-branded search referrals to Harvard’s website. Specifically when senior university leaders and faculty speak at events, Perry can start to measure which new keywords people use to learn more about the topics and speakers.
Perry says, "At Harvard University, analytics have become an essential part of our digital communications strategy. Services like the Target Towns report help us understand what resonates where -- and are an interesting new complement to the Google Analytics capabilities we already use."
We’re thrilled to see developers overcoming challenges and solving business problems with the API. If you have done some exciting work with the Google Analytics platform, lets us know in the comments. We love to hear your stories.