What's the output format when using ga:country

247 views
Skip to first unread message

tytung

unread,
Jun 26, 2010, 8:25:26 AM6/26/10
to google-analytics-api - GA Data Export API
Part1:
When I use the following URL, I can get a list of countries and
corresponding pageviews.
But what's the format of the returning country names?
How can I convert these country names to another format?

// The feed URI that is used for retrieving the analytics data
var feedUri = 'https://www.google.com/analytics/feeds/data' +
'?start-date=2009-01-01' +
'&end-date=2010-05-31' +
'&dimensions=ga:country' +
'&metrics=ga:pageviews' +
'&sort=ga:pageviews' +
'&ids=' + document.getElementById('tableid').value;


e.g.
'United States', 300
'Japan', 150
'Germany', 200
......
---------------------------------------------------------------------------­---
Part2:
When I use these country names to generate a *Geomap* by using Google
Visualization API, these country names above works and I can get a
flash geomap.


http://code.google.com/intl/zh-TW/apis/visualization/documentation/ga...


function drawMap() {
var data = new google.visualization.DataTable();
data.addRows(6);
data.addColumn('string', 'Country');
data.addColumn('number', 'Popularity');
data.setValue(0, 0, 'Germany');
data.setValue(0, 1, 200);
data.setValue(1, 0, 'United States');
data.setValue(1, 1, 300);
... skip ...


---------------------------------------------------------------------------­--
Part3:
However, when I use these country names to generate a *Intensity Map*
by using Google Visualization API, these country names NOT works and
I
get a flash map without any color on the map.


http://code.google.com/intl/zh-TW/apis/visualization/documentation/ga...


The above webpage says that I should use "ISO 3166-1-alpha-2 codes"
for countries.
How can I convert the country names produced by using 'ga:country' in
Google Analytics Data Export API to the ISO 3166-1-alpha-2 codes?


Thanks.

Message has been deleted

tytung

unread,
Jun 26, 2010, 8:47:09 AM6/26/10
to google-analytics-api - GA Data Export API
1. The NOT working code for Intensity Map. Because the country names
are wrong format.
----------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" /
>
<meta http-equiv="pragma" content="no-cache" />

<title></title>
<script type="text/javascript" src="http://www.google.com/jsapi"></
script>
<script type="text/javascript">
google.load('visualization', '1', {packages: ['intensitymap']});

function drawVisualization() {
var data = new google.visualization.DataTable();
data.addRows(3);
data.addColumn('string', 'Country');
data.addColumn('number', 'Views');

data.setValue(0, 0, 'United States');
data.setValue(0, 1, 300);

data.setValue(1, 0, 'Japan');
data.setValue(1, 1, 150);

data.setValue(2, 0, 'Germany');
data.setValue(2, 1, 200);

var container = document.getElementById('visualization');
var chart = new google.visualization.IntensityMap(container);
chart.draw(data, {});
}

google.setOnLoadCallback(drawVisualization);
</script>
</head>
<body>

<div id="visualization">Loading Flash ......</div>

</body>
</html>
----------------------


2. The working code for Intensity Map. Differences: ('Germany' ->
'DE', 'United States' -> 'US', 'Japan' -> 'JP')
------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" /
>
<meta http-equiv="pragma" content="no-cache" />

<title></title>
<script type="text/javascript" src="http://www.google.com/jsapi"></
script>
<script type="text/javascript">
google.load('visualization', '1', {packages: ['intensitymap']});

function drawVisualization() {
var data = new google.visualization.DataTable();
data.addRows(3);
data.addColumn('string', 'Country');
data.addColumn('number', 'Views');

data.setValue(0, 0, 'US');
data.setValue(0, 1, 300);

data.setValue(1, 0, 'JP');
data.setValue(1, 1, 150);

data.setValue(2, 0, 'DE');
data.setValue(2, 1, 200);

var container = document.getElementById('visualization');
var chart = new google.visualization.IntensityMap(container);
chart.draw(data, {});
}

google.setOnLoadCallback(drawVisualization);
</script>
</head>
<body>

<div id="visualization">Loading Flash ......</div>

</body>
</html>
------------------------

Nick

unread,
Jun 29, 2010, 1:08:48 PM6/29/10
to google-analytics-api - GA Data Export API
Ok,

Can you open a feature request if one doesn't already exist/ or add
comments to an existing one, so we can gauge how important this is for
everybody.

-Nick

tytung

unread,
Jun 30, 2010, 4:02:36 AM6/30/10
to google-analytics-api - GA Data Export API
Hello,

I just want to know the format of country names when using the
parameter ga:country?
If you are the API developer, can you tell me the exactly format?
If not, please forward this message to the original API developer,
thank you.

When I know the exactly format, I can translate the country names into
what I want by myself.
So I think It is not a feature request.

Tsaiyeh
> > > Thanks.- 隱藏被引用文字 -
>
> - 顯示被引用文字 -

tytung

unread,
Jun 30, 2010, 4:12:49 AM6/30/10
to google-analytics-api - GA Data Export API
I have found a feature request about ga:country in ISO Alpha-3.
http://code.google.com/p/gdata-issues/issues/detail?id=1684&can=1&q=label%3AAPI-Analytics

Please forget my previous post.
> > - 顯示被引用文字 -- 隱藏被引用文字 -
>
> - 顯示被引用文字 -

vishant....@grinfosys.com

unread,
Jul 11, 2013, 5:56:25 AM7/11/13
to google-analytics...@googlegroups.com
Hi,

Please let me know, if you got answer or code for your question. I am looking for same thing.

Thanks.
Reply all
Reply to author
Forward
0 new messages