Skip to content
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

Cohort report not returning expected values. #7213

Open
Jarno556564 opened this issue Apr 11, 2024 · 0 comments
Open

Cohort report not returning expected values. #7213

Jarno556564 opened this issue Apr 11, 2024 · 0 comments
Labels
type: question Request for information or clarification. Not an issue.

Comments

@Jarno556564
Copy link

Jarno556564 commented Apr 11, 2024

Environment details

OS: Ubuntu-22.04LTS (WSL)
PHP version: 7.4.33
Package name and version: google/analytics-data: 0.16.1

Hello I am working with the analytics data api to get some required data.

I have built up ~8 Google\Analytics\Data\V1beta\RunReportRequest objects that give me the required data.

But for my use case I need to make compare data from 2 date ranges. So I decided to look into cohort reports and see if they fit my use case.

    (new RunReportRequest())
        ->setProperty('properties/' . $property_id)
        ->setDimensions([
            new Dimension([
                'name' => 'cohort',
            ]),
            new Dimension([
                'name' => 'cohortNthDay',
            ])
        ])
        ->setMetrics([
            new Metric([
                'name' => 'cohortActiveUsers',
            ]),
        ])
        ->setCohortSpec(
            (new CohortSpec())
                ->setCohorts([
                    (new Cohort())
                        ->setDimension(
                            'firstSessionDate'
                        )
                        ->setDateRange(
                            new DateRange([ // format YYYY-MM-DD
                                'start_date' => '2023-12-01',
                                'end_date' => '2023-12-01',
                            ])
                        )
                ])
                ->setCohortsRange(
                    (new CohortsRange())
                        ->setGranularity(1)
                        ->setStartOffset(0)
                        ->setEndOffset(5)
                )
        ),

This is how my request is currently being built.

this is the output for $response->serializeToJsonString()

{
    "dimensionHeaders": [
        {
            "name": "cohort"
        },
        {
            "name": "cohortNthDay"
        }
    ],
    "metricHeaders": [
        {
            "name": "cohortActiveUsers",
            "type": "TYPE_INTEGER"
        }
    ],
    "rows": [
        {
            "dimensionValues": [
                {
                    "value": "cohort_0"
                },
                {
                    "value": "0000"
                }
            ],
            "metricValues": [
                {
                    "value": "13"
                }
            ]
        }
    ],
    "rowCount": 1,
    "metadata": {
        "currencyCode": "EUR",
        "timeZone": "Europe\/Amsterdam"
    },
    "kind": "analyticsData#runReport"
}

When I am expecting more values similair to
https://developers.google.com/analytics/devguides/reporting/data/v1/advanced#cohort_report_examples

I have tried these options to try and get a different output:

  • Many different start dates
  • Weekly/Monthly granularity
  • Many different start/end offsets

But I keep getting similair response data. Does anyone know why?

@ajupazhamayil ajupazhamayil added the type: question Request for information or clarification. Not an issue. label Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

2 participants