Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get google profile Id from tracking code?

I'm getting Google analytics using Google API. In order to get analytics I need to provide profile Id which looks like "ga:12345678".

The problem is that user can have many profiles. Is it possible to figure out profile Id from say Google tracking code (e.g. if I know tracking ID which looks like "UA-1234567-1")? Are they related to each other at all?

Thanks

like image 945
Burjua Avatar asked Mar 21 '11 15:03

Burjua


2 Answers

I had the same issue and I find out the simplest way to get google analytics profile id.

Log into Google Analytics

1.Access your site’s profile (get to the dashboard)

2.Your URL should look like:

https://www.google.com/analytics/web/#report/visitors-overview/a1234b23478970p987654/

/a1234b23478970p987654/

That last part, after the “p” is your Google Analytics Profile ID, in this case (this is a fake account) it is “987654”

like image 125
Gabber Avatar answered Nov 15 '22 09:11

Gabber


You can programatically get the profiles that exist for a given WebPropertyId (UA code) using the management API (link below).

The HTTP call you make will look like this:

https://www.google.com/analytics/feeds/datasources/ga/accounts/[accountID]/webproperties/[webPropertyID]/profiles

Where accountID and webPropertyID will either be set to the specific values you are interested in or ~all to bring back everything the current user has access to.

If by convention you don't create multiple profiles under a Web Property then only the default profile will be returned for a given WebPropertyId, which means you will be getting a one-to-one mapping from WebPropertyId to profile id. This will allow you to look up a profile id from a WebPropertyId.

See here on the management API docs for more info: http://code.google.com/apis/analytics/docs/mgmt/mgmtFeedReference.html

like image 22
stephen Avatar answered Nov 15 '22 08:11

stephen