/** * TODO(developer): Uncomment this variable and replace with your * Google Analytics 4 property ID before running the sample. */// propertyId = 'YOUR-GA4-PROPERTY-ID';// Imports the Google Analytics Data API client library.const{BetaAnalyticsDataClient}=require('@google-analytics/data');// Using a default constructor instructs the client to use the credentials// specified in GOOGLE_APPLICATION_CREDENTIALS environment variable.constanalyticsDataClient=newBetaAnalyticsDataClient();// Runs a simple report.asyncfunctionrunReport(){const[response]=awaitanalyticsDataClient.runReport({property: `properties/${propertyId}`,dateRanges: [{startDate: '2020-03-31',endDate: 'today',},],dimensions: [{name: 'city',},],metrics: [{name: 'activeUsers',},],});console.log('Report result:');response.rows.forEach(row=>{console.log(row.dimensionValues[0],row.metricValues[0]);});}runReport();
Samples
Samples are in the samples/ directory. Each sample's README.md has instructions for running its sample.
Our client libraries follow the Node.js release schedule.
Libraries are compatible with all current active and maintenance versions of
Node.js.
If you are using an end-of-life version of Node.js, we recommend that you update
as soon as possible to an actively supported LTS version.
Google's client libraries support legacy versions of Node.js runtimes on a
best-efforts basis with the following warnings:
Legacy versions are not tested in continuous integration.
Some security patches and features cannot be backported.
Dependencies cannot be kept up-to-date.
Client libraries targeting some end-of-life versions of Node.js are available, and
can be installed through npm dist-tags.
The dist-tags follow the naming convention legacy-(version).
For example, npm install @google-analytics/data@legacy-8 installs client libraries
for versions compatible with Node.js 8.
This library is considered to be in preview. This means it is still a
work-in-progress and under active development. Any release is subject to
backwards-incompatible changes at any time.
Please note that this README.md, the samples/README.md,
and a variety of configuration files in this repository (including .nycrc and tsconfig.json)
are generated from a central template. To edit one of these files, make an edit
to its templates in
directory.
Thanks for stopping by to let us know something could be better!
PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] Describe the solution you'd like
A clear and concise description of what you want to happen. Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered. Additional context
Add any other context or screenshots about the feature request here.
Command failed: node ./runReportWithNamedDateRanges.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
Error: Command failed: node ./runReportWithNamedDateRanges.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
at checkExecSyncError (child_process.js:635:11)
at Object.execSync (child_process.js:671:15)
at execSync (test/runReportWithNamedDateRanges.test.js:24:28)
at Context.<anonymous> (test/runReportWithNamedDateRanges.test.js:31:20)
at processImmediate (internal/timers.js:461:21)</pre></details>
Command failed: node ./quickstart.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
Error: Command failed: node ./quickstart.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
at checkExecSyncError (child_process.js:635:11)
at Object.execSync (child_process.js:671:15)
at execSync (test/quickstart.test.js:24:28)
at Context.<anonymous> (test/quickstart.test.js:31:20)
at processImmediate (internal/timers.js:461:21)</pre></details>
Command failed: node ./runRealtimeReport.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
Error: Command failed: node ./runRealtimeReport.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
at checkExecSyncError (child_process.js:635:11)
at Object.execSync (child_process.js:671:15)
at execSync (test/runRealtimeReport.test.js:24:28)
at Context.<anonymous> (test/runRealtimeReport.test.js:31:20)
at processImmediate (internal/timers.js:461:21)</pre></details>
Command failed: node ./quickstart_json_credentials.js 222596558 /secrets/gfile/service-account.json
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
Error: Command failed: node ./quickstart_json_credentials.js 222596558 /secrets/gfile/service-account.json
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
at checkExecSyncError (child_process.js:635:11)
at Object.execSync (child_process.js:671:15)
at execSync (test/quickstart_json_credentials.test.js:24:28)
at Context.<anonymous> (test/quickstart_json_credentials.test.js:34:20)
at processImmediate (internal/timers.js:461:21)</pre></details>
Thanks for stopping by to ask us a question! Please make sure to include:
What you're trying to do
I'm trying to import @google-analytics/data
What code you've already tried
Any error messages you're getting
PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.
Command failed: node ./runReportWithDimensionExcludeFilter.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
Error: Command failed: node ./runReportWithDimensionExcludeFilter.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
at checkExecSyncError (child_process.js:635:11)
at Object.execSync (child_process.js:671:15)
at execSync (test/runReportWithDimensionExcludeFilter.test.js:24:28)
at Context.<anonymous> (test/runReportWithDimensionExcludeFilter.test.js:31:20)
at processImmediate (internal/timers.js:461:21)</pre></details>
The only sample you appear to have works with service accounts. Does this library also support normal Oauth2 authentication or just service account authentication?
I tried setting the GOOGLE_APPLICATION_CREDENTIALS to a normal Oauth2 cred file and i get the following error message.
(node:14561) UnhandledPromiseRejectionWarning: Error: The incoming JSON object does not contain a client_email field
at JWT.fromJSON (/home/linda/WebstormProjects/google_nodejs_samples/node_modules/google-gax/node_modules/google-auth-library/build/src/auth/jwtclient.js:195:19)
at GoogleAuth._cacheClientFromJSON (/home/linda/WebstormProjects/google_nodejs_samples/node_modules/google-gax/node_modules/google-auth-library/build/src/auth/googleauth.js:301:16)
at ReadStream.<anonymous> (/home/linda/WebstormProjects/google_nodejs_samples/node_modules/google-gax/node_modules/google-auth-library/build/src/auth/googleauth.js:335:36)
at ReadStream.emit (events.js:228:7)
at endReadableNT (_stream_readable.js:1185:12)
at processTicksAndRejections (internal/process/task_queues.js:81:21)
Command failed: node ./runReportWithCohorts.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
Error: Command failed: node ./runReportWithCohorts.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
at checkExecSyncError (child_process.js:635:11)
at Object.execSync (child_process.js:671:15)
at execSync (test/runReportWithCohorts.test.js:24:28)
at Context.<anonymous> (test/runReportWithCohorts.test.js:31:20)
at processImmediate (internal/timers.js:461:21)</pre></details>
Command failed: node ./runReportWithDimensionAndMetricFilters.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
Error: Command failed: node ./runReportWithDimensionAndMetricFilters.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
at checkExecSyncError (child_process.js:635:11)
at Object.execSync (child_process.js:671:15)
at execSync (test/runReportWithDimensionAndMetricFilters.test.js:24:28)
at Context.<anonymous> (test/runReportWithDimensionAndMetricFilters.test.js:31:20)
at processImmediate (internal/timers.js:461:21)</pre></details>
Command failed: node ./getMetadataByPropertyId.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
Error: Command failed: node ./getMetadataByPropertyId.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
at checkExecSyncError (child_process.js:635:11)
at Object.execSync (child_process.js:671:15)
at execSync (test/getMetadataByPropertId.test.js:24:28)
at Context.<anonymous> (test/getMetadataByPropertId.test.js:31:20)
at processImmediate (internal/timers.js:461:21)</pre></details>
ux1_x86_64.whl
Collecting protobuf==3.13.0 (from -r /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/gapic_generator_python/requirements.txt (line 6))
Using cached https://files.pythonhosted.org/packages/30/79/510974552cebff2ba04038544799450defe75e96ea5f1675dbf72cc8744f/protobuf-3.13.0-cp36-cp36m-manylinux1_x86_64.whl
Saved ./protobuf-3.13.0-cp36-cp36m-manylinux1_x86_64.whl
Collecting pypandoc==1.5 (from -r /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/gapic_generator_python/requirements.txt (line 7))
Using cached https://files.pythonhosted.org/packages/d6/b7/5050dc1769c8a93d3ec7c4bd55be161991c94b8b235f88bf7c764449e708/pypandoc-1.5.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmpfs/tmp/tmpj4n7o3ft/setuptools-tmp/setuptools/__init__.py", line 6, in <module>
import distutils.core
File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/_distutils_hack/__init__.py", line 83, in create_module
return importlib.import_module('setuptools._distutils')
File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named 'setuptools._distutils'
----------------------------------------
(Command "python setup.py egg_info" failed with error code 1 in /tmpfs/tmp/pip-build-20x9_gmb/pypandoc/
)
ERROR: no such package '@gapic_generator_python_pip_deps//': pip_import failed: Collecting click==7.1.2 (from -r /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/gapic_generator_python/requirements.txt (line 1))
Using cached https://files.pythonhosted.org/packages/d2/3d/fa76db83bf75c4f8d338c2fd15c8d33fdd7ad23a9b5e57eb6c5de26b430e/click-7.1.2-py2.py3-none-any.whl
Saved ./click-7.1.2-py2.py3-none-any.whl
Collecting google-api-core==1.22.1 (from -r /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/gapic_generator_python/requirements.txt (line 2))
Using cached https://files.pythonhosted.org/packages/e0/2d/7c6c75013105e1d2b6eaa1bf18a56995be1dbc673c38885aea31136e9918/google_api_core-1.22.1-py2.py3-none-any.whl
Saved ./google_api_core-1.22.1-py2.py3-none-any.whl
Collecting googleapis-common-protos==1.52.0 (from -r /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/gapic_generator_python/requirements.txt (line 3))
Using cached https://files.pythonhosted.org/packages/03/74/3956721ea1eb4bcf7502a311fdaa60b85bd751de4e57d1943afe9b334141/googleapis_common_protos-1.52.0-py2.py3-none-any.whl
Saved ./googleapis_common_protos-1.52.0-py2.py3-none-any.whl
Collecting jinja2==2.11.2 (from -r /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/gapic_generator_python/requirements.txt (line 4))
Using cached https://files.pythonhosted.org/packages/30/9e/f663a2aa66a09d838042ae1a2c5659828bb9b41ea3a6efa20a20fd92b121/Jinja2-2.11.2-py2.py3-none-any.whl
Saved ./Jinja2-2.11.2-py2.py3-none-any.whl
Collecting MarkupSafe==1.1.1 (from -r /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/gapic_generator_python/requirements.txt (line 5))
Using cached https://files.pythonhosted.org/packages/b2/5f/23e0023be6bb885d00ffbefad2942bc51a620328ee910f64abe5a8d18dd1/MarkupSafe-1.1.1-cp36-cp36m-manylinux1_x86_64.whl
Saved ./MarkupSafe-1.1.1-cp36-cp36m-manylinux1_x86_64.whl
Collecting protobuf==3.13.0 (from -r /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/gapic_generator_python/requirements.txt (line 6))
Using cached https://files.pythonhosted.org/packages/30/79/510974552cebff2ba04038544799450defe75e96ea5f1675dbf72cc8744f/protobuf-3.13.0-cp36-cp36m-manylinux1_x86_64.whl
Saved ./protobuf-3.13.0-cp36-cp36m-manylinux1_x86_64.whl
Collecting pypandoc==1.5 (from -r /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/gapic_generator_python/requirements.txt (line 7))
Using cached https://files.pythonhosted.org/packages/d6/b7/5050dc1769c8a93d3ec7c4bd55be161991c94b8b235f88bf7c764449e708/pypandoc-1.5.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmpfs/tmp/tmpj4n7o3ft/setuptools-tmp/setuptools/__init__.py", line 6, in <module>
import distutils.core
File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/_distutils_hack/__init__.py", line 83, in create_module
return importlib.import_module('setuptools._distutils')
File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named 'setuptools._distutils'
----------------------------------------
(Command "python setup.py egg_info" failed with error code 1 in /tmpfs/tmp/pip-build-20x9_gmb/pypandoc/
)
INFO: Elapsed time: 2.572s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
FAILED: Build did NOT complete successfully (0 packages loaded)
Traceback (most recent call last):
File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/tmpfs/src/github/synthtool/synthtool/__main__.py", line 102, in <module>
main()
File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/tmpfs/src/github/synthtool/synthtool/__main__.py", line 94, in main
spec.loader.exec_module(synth_module) # type: ignore
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/kbuilder/.cache/synthtool/nodejs-analytics-data/synth.py", line 31, in <module>
bazel_target=f"//google/analytics/data/{version}:google-analytics-data-{version}-nodejs"
File "/tmpfs/src/github/synthtool/synthtool/gcp/gapic_bazel.py", line 52, in node_library
return self._generate_code(service, version, "nodejs", **kwargs)
File "/tmpfs/src/github/synthtool/synthtool/gcp/gapic_bazel.py", line 183, in _generate_code
shell.run(bazel_run_args)
File "/tmpfs/src/github/synthtool/synthtool/shell.py", line 39, in run
raise exc
File "/tmpfs/src/github/synthtool/synthtool/shell.py", line 33, in run
encoding="utf-8",
File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/subprocess.py", line 438, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['bazel', '--max_idle_secs=240', 'build', '//google/analytics/data/v1alpha:google-analytics-data-v1alpha-nodejs']' returned non-zero exit status 1.
spec.loader.exec_module(synth_module) # type: ignore
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/kbuilder/.cache/synthtool/nodejs-analytics-data/synth.py", line 31, in <module>
bazel_target=f"//google/analytics/data/{version}:google-analytics-data-{version}-nodejs"
File "/tmpfs/src/github/synthtool/synthtool/gcp/gapic_bazel.py", line 52, in node_library
return self._generate_code(service, version, "nodejs", **kwargs)
File "/tmpfs/src/github/synthtool/synthtool/gcp/gapic_bazel.py", line 183, in _generate_code
shell.run(bazel_run_args)
File "/tmpfs/src/github/synthtool/synthtool/shell.py", line 39, in run
raise exc
File "/tmpfs/src/github/synthtool/synthtool/shell.py", line 33, in run
encoding="utf-8",
File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/subprocess.py", line 438, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['bazel', '--max_idle_secs=240', 'build', '//google/analytics/data/v1alpha:google-analytics-data-v1alpha-nodejs']' returned non-zero exit status 1.
2020-09-02 02:16:57,430 autosynth [ERROR] > Synthesis failed
2020-09-02 02:16:57,430 autosynth [DEBUG] > Running: git clean -fdx
Removing __pycache__/
Traceback (most recent call last):
File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 690, in <module>
main()
File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 539, in main
return _inner_main(temp_dir)
File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 630, in _inner_main
).synthesize(synth_log_path / "sponge_log.log")
File "/tmpfs/src/github/synthtool/autosynth/synthesizer.py", line 120, in synthesize
synth_proc.check_returncode() # Raise an exception.
File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/subprocess.py", line 389, in check_returncode
self.stderr)
subprocess.CalledProcessError: Command '['/tmpfs/src/github/synthtool/env/bin/python3', '-m', 'synthtool', '--metadata', 'synth.metadata', 'synth.py', '--']' returned non-zero exit status 1.
Google internal developers can see the full log here.
Command failed: node ./runReportWithMultipleDimensionFilters.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
Error: Command failed: node ./runReportWithMultipleDimensionFilters.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
at checkExecSyncError (child_process.js:635:11)
at Object.execSync (child_process.js:671:15)
at execSync (test/runReportWithMultipleDimensionFilters.test.js:24:28)
at Context.<anonymous> (test/runReportWithMultipleDimensionFilters.test.js:31:20)
at processImmediate (internal/timers.js:461:21)</pre></details>
Command failed: node ./runReportWithPagination.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
Error: Command failed: node ./runReportWithPagination.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
at checkExecSyncError (child_process.js:635:11)
at Object.execSync (child_process.js:671:15)
at execSync (test/runReportWithPagination.test.js:24:28)
at Context.<anonymous> (test/runReportWithPagination.test.js:31:20)
at processImmediate (internal/timers.js:461:21)</pre></details>
Command failed: node ./runReportWithDimensionFilter.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
Error: Command failed: node ./runReportWithDimensionFilter.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
at checkExecSyncError (child_process.js:635:11)
at Object.execSync (child_process.js:671:15)
at execSync (test/runReportWithDimensionFilter.test.js:24:28)
at Context.<anonymous> (test/runReportWithDimensionFilter.test.js:31:20)
at processImmediate (internal/timers.js:461:21)</pre></details>
Command failed: node ./runReportWithDateRanges.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
Error: Command failed: node ./runReportWithDateRanges.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
at checkExecSyncError (child_process.js:635:11)
at Object.execSync (child_process.js:671:15)
at execSync (test/runReportWithDateRanges.test.js:24:28)
at Context.<anonymous> (test/runReportWithDateRanges.test.js:31:20)
at processImmediate (internal/timers.js:461:21)</pre></details>
// Explicitly use service account credentials by specifying
// the private key file.
const analyticsDataClient = new BetaAnalyticsDataClient({
keyFilename: credentialsJsonPath,
});
can I give JSON content of the keyfile here somehow, that will be great for me
I want to retrieve the data from GA using this repo, I have finished the configurations in the Before you begin sections in Quick Start, when I used the sample codes, I encountered below errors, does anyone know why? thanks in advance.
below is my sample codes I'm using.
Process 189 exited with code 2.
Error: Process 189 exited with code 2.
at ChildProcess. (node_modules/pack-n-play/build/src/utils.js:48:22)
-> /workspace/node_modules/pack-n-play/src/utils.ts:62:11
at maybeClose (internal/child_process.js:1022:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
Command failed: node ./runReportWithMultipleMetrics.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
Error: Command failed: node ./runReportWithMultipleMetrics.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
at checkExecSyncError (child_process.js:635:11)
at Object.execSync (child_process.js:671:15)
at execSync (test/runReportWithMultipleMetrics.test.js:24:28)
at Context.<anonymous> (test/runReportWithMultipleMetrics.test.js:31:20)
at processImmediate (internal/timers.js:461:21)</pre></details>
There are many application use cases where environment variables can only be defined so there should be an option to pass JSON data instead of file path for flexibility
Command failed: node ./runRealtimeReportWithMultipleDimensions.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
Error: Command failed: node ./runRealtimeReportWithMultipleDimensions.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
at checkExecSyncError (child_process.js:635:11)
at Object.execSync (child_process.js:671:15)
at execSync (test/runRealtimeReportWithMultipleDimensions.test.js:24:28)
at Context.<anonymous> (test/runRealtimeReportWithMultipleDimensions.test.js:31:20)
at processImmediate (internal/timers.js:461:21)</pre></details>
Command failed: node ./runRealtimeReportWithMultipleMetrics.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
Error: Command failed: node ./runRealtimeReportWithMultipleMetrics.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
at checkExecSyncError (child_process.js:635:11)
at Object.execSync (child_process.js:671:15)
at execSync (test/runRealtimeReportWithMultipleMetrics.test.js:24:28)
at Context.<anonymous> (test/runRealtimeReportWithMultipleMetrics.test.js:31:20)
at processImmediate (internal/timers.js:461:21)</pre></details>
Command failed: node ./runPivotReport.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
Error: Command failed: node ./runPivotReport.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
at checkExecSyncError (child_process.js:635:11)
at Object.execSync (child_process.js:671:15)
at execSync (test/runPivotReport.test.js:24:28)
at Context.<anonymous> (test/runPivotReport.test.js:31:20)
at processImmediate (internal/timers.js:461:21)</pre></details>
Im not even sure if my dimensions or metrics values above are correct, they are complete guesses in regards to my goal of trying to get page view counts.
I am wondering though, what is the value here? Is this the number of page views this route has seen? There doesn't seem to be much explanation as to what this actually is.
Command failed: node ./getCommonMetadata.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
Error: Command failed: node ./getCommonMetadata.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
at checkExecSyncError (child_process.js:635:11)
at Object.execSync (child_process.js:671:15)
at execSync (test/getCommonMetadata.test.js:24:28)
at Context.<anonymous> (test/getCommonMetadata.test.js:31:20)
at processImmediate (internal/timers.js:461:21)</pre></details>
Command failed: node ./runReportWithMultipleDimensions.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
Error: Command failed: node ./runReportWithMultipleDimensions.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
at checkExecSyncError (child_process.js:635:11)
at Object.execSync (child_process.js:671:15)
at execSync (test/runReportWithMultipleDimensions.test.js:24:28)
at Context.<anonymous> (test/runReportWithMultipleDimensions.test.js:31:20)
at processImmediate (internal/timers.js:461:21)</pre></details>
Command failed: node ./runBatchReport.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
Error: Command failed: node ./runBatchReport.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
at checkExecSyncError (child_process.js:635:11)
at Object.execSync (child_process.js:671:15)
at execSync (test/runBatchReport.test.js:24:28)
at Context.<anonymous> (test/runBatchReport.test.js:31:20)
at processImmediate (internal/timers.js:461:21)</pre></details>
Command failed: node ./runReportWithAggregations.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
Error: Command failed: node ./runReportWithAggregations.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
at checkExecSyncError (child_process.js:635:11)
at Object.execSync (child_process.js:671:15)
at execSync (test/runReportWithAggregations.test.js:24:28)
at Context.<anonymous> (test/runReportWithAggregations.test.js:31:20)
at processImmediate (internal/timers.js:461:21)</pre></details>
Command failed: node ./runReportWithOrdering.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
Error: Command failed: node ./runReportWithOrdering.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
at checkExecSyncError (child_process.js:635:11)
at Object.execSync (child_process.js:671:15)
at execSync (test/runReportWithOrdering.test.js:24:28)
at Context.<anonymous> (test/runReportWithOrdering.test.js:31:20)
at processImmediate (internal/timers.js:461:21)</pre></details>
Command failed: node ./runReportWithPropertyQuota.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
Error: Command failed: node ./runReportWithPropertyQuota.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
at checkExecSyncError (child_process.js:635:11)
at Object.execSync (child_process.js:671:15)
at execSync (test/runReportWithPropertyQuota.test.js:24:28)
at Context.<anonymous> (test/runReportWithPropertyQuota.test.js:31:20)
at processImmediate (internal/timers.js:461:21)</pre></details>
Command failed: node ./runReport.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
Error: Command failed: node ./runReport.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
at checkExecSyncError (child_process.js:635:11)
at Object.execSync (child_process.js:671:15)
at execSync (test/runReport.test.js:24:28)
at Context.<anonymous> (test/runReport.test.js:31:20)
at processImmediate (internal/timers.js:461:21)</pre></details>
Is your feature request related to a problem? Please describe.
There seems to be a missing metric about Exits / Exit Rate (see https://support.google.com/analytics/answer/2525491). This would be particularly useful in combination with the dimension unifiedPagePathScreen to detect the exit rate for each pages.
Describe the solution you'd like
Make the Exit available from Google Analytics Data API
Describe alternatives you've considered
Could not find a good alternative to this metric missing : we had to to check the value manually in GA 4 console.
Command failed: node ./runReportWithDimensionInListFilter.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
Error: Command failed: node ./runReportWithDimensionInListFilter.js 222596558
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
at checkExecSyncError (child_process.js:635:11)
at Object.execSync (child_process.js:671:15)
at execSync (test/runReportWithDimensionInListFilter.test.js:24:28)
at Context.<anonymous> (test/runReportWithDimensionInListFilter.test.js:31:20)
at processImmediate (internal/timers.js:461:21)</pre></details>