Search code examples
google-analyticsgoogle-analytics-api

Discrepancy between keyword visits and API keyword visits in Google Analytics API


To Stack Overflow:

I posted the question below on the GAPI Google Group but have failed to get any reply. This is a last ditch attempt for anyone that knows anything about the Analytics API.

I have posted my original question below.

Dan


Hi all,

We're having a problem with our of our accounts whereby the data from the Analytics interface isn't matching what we are getting from the API.

We have a website that is split into a number of "subsites" under one GA account. To view data for the subsite, I have setup an advanced segment with the following filters:

ga:pagePath=@/foo/bar/site

To view my keywords in the interface, I select this advanced segment and then navigate to Traffic Sources -> Sources -> Search -> Organic and select May as the date range. I then receive a list of keywords with associated visits. At the top of this list is the (not provided) keyword which has received 157 visits.

To emulate this query in the API, I run the following request...

Filters: ga:medium==organic;ga:pagePath=@/foo/bar/site Dimensions: ga:keyword Metrics: ga:visits Sort: -ga:visits Start Date: 2013-05-01 End Date: 2013-05-31

I receive a list of keywords back from the API which are (mostly) identical to those in the GA interface. However, the visit counts are much lower. For example, the (not provided) keyword which has 157 visits in the GA interface has only 39 visits in the API.

I have checked (and double checked) my dates and my query and I just can't find a reason for this discrepancy.

The only difference that I can identify is use of the advanced segment but surely this should simply match my API filter.

If anyone could shine some light on this, I would greatly appreciate it!

Dan


Solution

  • This is most likely because the queries between the two are not actually the same. If you're using an advanced segment in the UI then you should do the same with the API.

    Try this:

    • Dimensions: ga:keyword
    • Metrics: ga:visits
    • Sort: -ga:visits
    • Start Date: 2013-05-01 End Date: 2013-05-31
    • Segment: dynamic::ga:pagePath=@/foo/bar/site
    • Filters: ga:medium==organic