@robinpath/google-analytics
0.1.1Node.jsPublicGoogle Analytics module for RobinPath.
Google Analytics
Google Analytics module for RobinPath.
Package: @robinpath/google-analytics | Category: Productivity | Type: Integration
Authentication
google-analytics.setCredentials "your-credentials"
Call this once at the start of your script before using any other function. Credentials persist for the duration of the script execution.
Use Cases
Use the google-analytics module when you need to:
- runReport -- Use
google-analytics.runReportto perform this operation - runRealtimeReport -- Use
google-analytics.runRealtimeReportto perform this operation - batchRunReports -- Use
google-analytics.batchRunReportsto perform this operation - runPivotReport -- Use
google-analytics.runPivotReportto perform this operation - getMetadata -- Use
google-analytics.getMetadatato perform this operation
Quick Reference
| Function | Description | Returns |
|---|---|---|
setCredentials | Configure google-analytics credentials. | object |
runReport | runReport | object |
runRealtimeReport | runRealtimeReport | object |
batchRunReports | batchRunReports | object |
runPivotReport | runPivotReport | object |
getMetadata | getMetadata | object |
listProperties | listProperties | object |
getProperty | getProperty | object |
listAccounts | listAccounts | object |
getActiveUsers | getActiveUsers | object |
getPageViews | getPageViews | object |
getTopPages | getTopPages | object |
getTrafficSources | getTrafficSources | object |
getUserDemographics | getUserDemographics | object |
getConversions | getConversions | object |
Functions
setCredentials
Configure google-analytics credentials.
Module: google-analytics | Returns: object -- API response.
google-analytics.setCredentials
| Parameter | Type | Required | Description |
|---|---|---|---|
accessToken | string | Yes | accessToken |
propertyId | string | Yes | propertyId |
runReport
runReport
Module: google-analytics | Returns: object -- API response.
google-analytics.runReport
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
runRealtimeReport
runRealtimeReport
Module: google-analytics | Returns: object -- API response.
google-analytics.runRealtimeReport
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
batchRunReports
batchRunReports
Module: google-analytics | Returns: object -- API response.
google-analytics.batchRunReports
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
runPivotReport
runPivotReport
Module: google-analytics | Returns: object -- API response.
google-analytics.runPivotReport
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
getMetadata
getMetadata
Module: google-analytics | Returns: object -- API response.
google-analytics.getMetadata
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
listProperties
listProperties
Module: google-analytics | Returns: object -- API response.
google-analytics.listProperties
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
getProperty
getProperty
Module: google-analytics | Returns: object -- API response.
google-analytics.getProperty
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
listAccounts
listAccounts
Module: google-analytics | Returns: object -- API response.
google-analytics.listAccounts
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
getActiveUsers
getActiveUsers
Module: google-analytics | Returns: object -- API response.
google-analytics.getActiveUsers
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
getPageViews
getPageViews
Module: google-analytics | Returns: object -- API response.
google-analytics.getPageViews
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
getTopPages
getTopPages
Module: google-analytics | Returns: object -- API response.
google-analytics.getTopPages
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
getTrafficSources
getTrafficSources
Module: google-analytics | Returns: object -- API response.
google-analytics.getTrafficSources
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
getUserDemographics
getUserDemographics
Module: google-analytics | Returns: object -- API response.
google-analytics.getUserDemographics
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
getConversions
getConversions
Module: google-analytics | Returns: object -- API response.
google-analytics.getConversions
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
Error Handling
All functions throw on failure. Common errors:
| Error | Cause |
|---|---|
GoogleAnalytics API error (${res.status}): ${t} | Check the error message for details |
google-analytics.setCredentials requires accessToken, propertyId. | Check the error message for details |
GoogleAnalytics: "..." not configured. Call google-analytics.setCredentials first. | Check the error message for details |
@desc "Validate result"
do
set $result as google-analytics.runReport
if $result != null
print "Success"
else
print "No result"
end
enddo
Recipes
1. List and iterate Metadata
Retrieve all items and loop through them.
@desc "Iterate results"
do
google-analytics.setCredentials $token
set $result as google-analytics.getMetadata
each $item in $result
print $item
end
enddo
2. Multi-step Google Analytics workflow
Chain multiple google-analytics operations together.
@desc "Execute operation"
do
google-analytics.setCredentials $token
set $r_runReport as google-analytics.runReport
set $r_runRealtimeReport as google-analytics.runRealtimeReport
set $r_batchRunReports as google-analytics.batchRunReports
print "All operations complete"
enddo
3. Safe runReport with validation
Check results before proceeding.
@desc "Validate result"
do
google-analytics.setCredentials $token
set $result as google-analytics.runReport
if $result != null
print "Success: " + $result
else
print "Operation returned no data"
end
enddo
Related Modules
- google-sheets -- Google Sheets module for complementary functionality
- google-calendar -- Google Calendar module for complementary functionality
- google-contacts -- Google Contacts module for complementary functionality
- google-forms -- Google Forms module for complementary functionality
- gmail -- Gmail module for complementary functionality
Versions (1)
| Version | Tag | Published |
|---|---|---|
| 0.1.1 | latest | 1 months ago |
Related Modules
rightplace
JS@robinpathv0.1.3
RightPlace integration — 130 functions for projects, WordPress, WooCommerce, email, files, git, spreadsheets, stages, docs, automations via rightplace-cli
asana
JS@robinpathv0.1.2
Asana module for RobinPath.
google-sheets
JS@robinpathv0.1.1
Google Sheets module for RobinPath.
airtable
JS@robinpathv0.1.2
Airtable module for RobinPath.
$ robinpath add @robinpath/google-analytics
