Peter Tharwat
Peter Tharwat

Reputation: 1

How can i filter data from google adsense api using page url?

i need to send custom filter to google adsense api v2

something like this


$optParams = array(
  'filters' => array(
    "URL_CHANNEL_NAME=@https://example.com/test/*"
    //or "URL_CHANNEL_NAME==https://example.com/test/"
  )
);

to get only earnings for this url "https://example.com/test" or "https://example.com/test/*"

i have tried "URL_CHANNEL_NAME==https://example.com/test/" or even "URL_CHANNEL_NAME==https://example.com/test/" but reponse always null enter image description here

Upvotes: 0

Views: 298

Answers (1)

zanderwar
zanderwar

Reputation: 3730

You can use regex to target all channels that begin with a certain URL

$optParams = [
    'filters' => [
        'URL_CHANNEL_NAME=@^https://example\.com/test'
     ]
);

There is also "contains" but "contains" with URLs can in edge-case scenarios return undesirable results:

URL_CHANNEL_NAME@https://example.com/test

It also could just have no data for the date range you're using, you won't receive anything if that is the case.

Upvotes: 0

Related Questions