I’m integrating an API for loading data from the Google Analytics Reporting API v4.
Here, I need to find the transaction count based on ‘ga:medium’ and ‘ga:pagePath.’
For example, let’s say I have 10 transactions with different mediums for various page paths. I want to load the transaction data for a specific page path and determine which medium it occurred under.
I’ve tried different approaches but haven’t found a solution yet.
Can someone help me find a solution?
`$metrics = [
'users' => 'ga:users',
'transactions' => 'ga:transactions',
];
$dimensions = [
'ga:pagePath',
'ga:medium'
]
// Create the ReportRequest object.
$request = new Google_Service_AnalyticsReporting_ReportRequest();
$request->setViewId($viewId);
// Create the DateRange object.
$dateRange = $this->getDateRange($startDate, $endDate);
$request->setDateRanges($dateRange);
$metrics = $this->getAnalyticsReportingMetrics($metricsArray);
$request->setMetrics($metrics);
$dimensionObj = $this->getAnalyticsReportingDimensions([$dimension]);
$request->setDimensions($dimensionObj);
// Set the sampling level
$request->setSamplingLevel("LARGE"); // or "SMALL" or "DEFAULT"
New contributor
user2798981 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.