-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Where are the examples (or docs for that matter) about filters??? #1590
Comments
Hi @php4fan use Google\Analytics\Data\V1beta\BetaAnalyticsDataClient;
use Google\Analytics\Data\V1beta\RunReportRequest;
use Google\Analytics\Data\V1beta\Dimension;
use Google\Analytics\Data\V1beta\Metric;
use Google\Analytics\Data\V1beta\DateRange;
use Google\Analytics\Data\V1beta\Filter;
use Google\Analytics\Data\V1beta\FilterExpression;
$client = new BetaAnalyticsDataClient();
$propertyId = 'YOUR-GA4-PROPERTY-ID';
$dimension = (new Dimension())
->setName('date');
$metric = (new Metric())
->setName('eventCount');
$dateRange = (new DateRange())
->setStartDate('7daysAgo')
->setEndDate('yesterday');
$stringFilter = (new Filter\StringFilter())
->setValue('first_open');
$filter = (new Filter())
->setFieldName('eventName')
->setStringFilter($stringFilter);
$filterExprssion = (new FilterExpression())
->setFilter($filter);
$response = $client->runReport([
'property' => 'properties/' . $propertyId,
'dimensions' => [$dimension],
'metrics' => [$metric],
'date_ranges' => [$dateRange],
'dimension_filter' => $filter,
]);
var_dump($response->serializeToJsonString()); I hope this helps. |
Have you added that to the docs? If so where? Otherwise why are you closing this as complete? |
@php4fan May be this could be helpful for you or anyone else
|
We can link the documentation to our samples that we already have generated in this repository. |
@bshaffer That would be great 👍 |
Where is the detailed documentation with examples, of how to build reports with complex (or even trivial) filters with the PHP library??
Here:
https://developers.google.com/analytics/devguides/reporting/data/v1/basics#dimension_filters
Some (too basic) example of filters in raw HTTP but no mention of PHP.
Here:
http://googleapis.github.io/google-cloud-php/#/docs/analytics-data/v0.8.0/analyticsdata/v1beta/readme
The only one example in PHP is one request, not only with no filters but with no parameters whatsoever.
Here:
https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/FilterExpression#StringFilter
Some more details about filters but no clue as to how to translate it into PHP code.
This is pathetic.
The text was updated successfully, but these errors were encountered: