CaptanU
CaptanU

Reputation: 33

How to you search UTM params using GA API

So I want to use GA API to create some automated reporting/tracking system.

I have already set service api etc, also have run few filters & metrics.

But I have no clue how to search for campaigns, UTM params, Acquisition, Hit URLs etc. params.

I did refer Hello Analytic reporting for service accounts.Using php api.

Is there any metric or filter like ga:newUsers or ga:session to get data UTM-wise?

Can someone please help with it? Even tutorials link will help. There isn't any decent documentation I could find.

Upvotes: 0

Views: 1607

Answers (1)

kgrg
kgrg

Reputation: 1633

You'll have to add 'filters' to parameters array passed to get function.

You can look for metrics and dimensions here. Although not the latest version, but she syntax of filter operators are explained here.

For example:

$optParams = array(
  'dimensions' => 'ga:date,ga:source,ga:medium',
  'filters' => 'ga:landingPagePath!@/admin/',
  'sort' => '-ga:sessions');

$ga_result = $analytics->data_ga->get( 'ga:' . $profileID,
                                           "2016-01-01",
                                           "2016-01-01",
                                           'ga:sessions,ga:pageviews,ga:bounces',
                                           $optParams);

Upvotes: 1

Related Questions