Collect combined data from content with different Urls in Google Analytics

Asked

Viewed 85 times

3

By collecting Google Analytics information for the local database, I end up consuming multiple requests for data relating to the same article on the web-site.

This occurred given the evolution of the same that is also reflected in changes in the URL:

# Query String
http://www.example.com/?modulo=artigos&chamada=ver&artigo=1

# Slugs
http://www.example.com/artigo/meu-artigo-fixe

# Sub-Domain
http://artigo.example.com/meu-artigo-fixe

Having each article three Urls, each one in Google Analytics, the code below is executed 3 times, one for each URL, in order to obtain the desired information:

$service = new Google_AnalyticsService($client);

$gaProfileID = 'ga:xxxxxxxx';
$startDate = '2000-01-01';
$endDate = date("Y-m-d", time());
$metrics = 'ga:sessions,ga:pageviews,ga:percentNewVisits';
$optParams = array(
    "filters" => "ga:pagePath==/".$urlDoArtigo // multiplas chamadas porque este valor muda
);

$results = $service->data_ga->get($gaProfileID, $startDate, $endDate, $metrics, $optParams);

Question

How to get data from each URL combined (summation) in a single call to Google Analytics ?

$ga_sessions = 'totalSessõesDosTrêsUrls'
$ga_pageviews = 'totalSessõesDosTrêsUrls'
$ga_percentNewVisits = 'totalPercentagemNovasVisitasDosTrêsUrls'
  • 1

    Have you ever tried to do "filters" => "ga:pagePath==/{$urlDoArtigo1};ga:pagePath==/{$urlDoArtigo2}"? where the ; is the operator AND.

  • @qmechanik I was reading an article about it last week, including a response in SOEN that suggested this, but I have not yet had the opportunity to perform tests to ascertain the outcome and/or implications. As soon as I have tested I come back here to inform and leave the relevant links.

  • Take a look at documentation from Google Analytics, has a way for you to capture events.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.