ga-extractor icon indicating copy to clipboard operation
ga-extractor copied to clipboard

Extracted JSON has no dates

Open zenminimalist opened this issue 2 years ago • 2 comments

Thank you, wise coding leader, for you have given us the power to break free of almighty Google chains of slavery and servitude!

I have tried my best to apply your wisdom, however failed.

My config.yaml looks like so:

dimensions:
- ga:pagePath
- ga:browser
- ga:operatingSystem
- ga:deviceCategory
- ga:browserSize
- ga:language
- ga:country
- ga:fullReferrer
endDate: '2023-06-30'
metrics:
- ga:pageviews
- ga:sessions
samplingLevel: DEFAULT
serviceAccountKeyPath: innate-temple-401817-XXXXX.json
startDate: '2017-01-02'
table: mytablenumberinGA 

The command ga-extractor auth gives me Successfully authenticated with user: XXXXXX

After using ga-extractor extract --report="My-Website.json" I do get a JSON file. However, that's only about 300KB for the timeframe. Upon inspection, I don't see any dates in the file, which is strange. I do see URL, dimension, countries,...

I tried ga-extractor migrate --format=CSV just to see what it would do with the extracted data and get the following error:

Traceback (most recent call last):
  File "/opt/homebrew/bin/ga-extractor", line 8, in <module>
    sys.exit(extractor())
             ^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/typer/main.py", line 214, in __call__
    return get_command(self)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/typer/main.py", line 532, in wrapper
    return callback(**use_params)  # type: ignore
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/ga_extractor/extractor.py", line 206, in migrate
    rows = __migrate_extract(scoped_credentials, config['table'], date_ranges)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/ga_extractor/extractor.py", line 250, in __migrate_extract
    rows[r["startDate"]] = response["reports"][0]["data"]["rows"]
                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'rows'

And just a side note: What is the "sample rate" for?

May the great Martin grace us with his presence and give us the wisdom we so desperately need in the time of terminal despair :)

zenminimalist avatar Oct 12 '23 19:10 zenminimalist

@MartinHeinz Would it be possible for you to test and see if your extraction with your GA account gives you dates? I have a suspicion (maybe completely unfounded) that Google changed something on their side.

zenminimalist avatar Oct 16 '23 18:10 zenminimalist

Just an update, no success...unfortunatey.

I tried recreating a new credentials, same issue. Then I tried out Plausible to see if their import works with my account. Ruling out something to do with my account. Works and imports the whole shabang. I assume they are using the same GA api.

Not sure why it only pulls in the headers with ga-extractor, resulting in 250 KB json whereas PA pulled in around 50k views.

Could it be anything with the type of credentials that are being used in ga-extractor vs PA and that with the type of credentials this project is using was changed by Google?

zenminimalist avatar Oct 26 '23 00:10 zenminimalist