Modules@robinpath/google-analytics
google-analytics

@robinpath/google-analytics

0.1.1Node.jsPublic

Google 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.runReport to perform this operation
  • runRealtimeReport -- Use google-analytics.runRealtimeReport to perform this operation
  • batchRunReports -- Use google-analytics.batchRunReports to perform this operation
  • runPivotReport -- Use google-analytics.runPivotReport to perform this operation
  • getMetadata -- Use google-analytics.getMetadata to perform this operation

Quick Reference

FunctionDescriptionReturns
setCredentialsConfigure google-analytics credentials.object
runReportrunReportobject
runRealtimeReportrunRealtimeReportobject
batchRunReportsbatchRunReportsobject
runPivotReportrunPivotReportobject
getMetadatagetMetadataobject
listPropertieslistPropertiesobject
getPropertygetPropertyobject
listAccountslistAccountsobject
getActiveUsersgetActiveUsersobject
getPageViewsgetPageViewsobject
getTopPagesgetTopPagesobject
getTrafficSourcesgetTrafficSourcesobject
getUserDemographicsgetUserDemographicsobject
getConversionsgetConversionsobject

Functions

setCredentials

Configure google-analytics credentials.

Module: google-analytics | Returns: object -- API response.

google-analytics.setCredentials
ParameterTypeRequiredDescription
accessTokenstringYesaccessToken
propertyIdstringYespropertyId

runReport

runReport

Module: google-analytics | Returns: object -- API response.

google-analytics.runReport
ParameterTypeRequiredDescription
inputstringNoInput parameter

runRealtimeReport

runRealtimeReport

Module: google-analytics | Returns: object -- API response.

google-analytics.runRealtimeReport
ParameterTypeRequiredDescription
inputstringNoInput parameter

batchRunReports

batchRunReports

Module: google-analytics | Returns: object -- API response.

google-analytics.batchRunReports
ParameterTypeRequiredDescription
inputstringNoInput parameter

runPivotReport

runPivotReport

Module: google-analytics | Returns: object -- API response.

google-analytics.runPivotReport
ParameterTypeRequiredDescription
inputstringNoInput parameter

getMetadata

getMetadata

Module: google-analytics | Returns: object -- API response.

google-analytics.getMetadata
ParameterTypeRequiredDescription
inputstringNoInput parameter

listProperties

listProperties

Module: google-analytics | Returns: object -- API response.

google-analytics.listProperties
ParameterTypeRequiredDescription
inputstringNoInput parameter

getProperty

getProperty

Module: google-analytics | Returns: object -- API response.

google-analytics.getProperty
ParameterTypeRequiredDescription
inputstringNoInput parameter

listAccounts

listAccounts

Module: google-analytics | Returns: object -- API response.

google-analytics.listAccounts
ParameterTypeRequiredDescription
inputstringNoInput parameter

getActiveUsers

getActiveUsers

Module: google-analytics | Returns: object -- API response.

google-analytics.getActiveUsers
ParameterTypeRequiredDescription
inputstringNoInput parameter

getPageViews

getPageViews

Module: google-analytics | Returns: object -- API response.

google-analytics.getPageViews
ParameterTypeRequiredDescription
inputstringNoInput parameter

getTopPages

getTopPages

Module: google-analytics | Returns: object -- API response.

google-analytics.getTopPages
ParameterTypeRequiredDescription
inputstringNoInput parameter

getTrafficSources

getTrafficSources

Module: google-analytics | Returns: object -- API response.

google-analytics.getTrafficSources
ParameterTypeRequiredDescription
inputstringNoInput parameter

getUserDemographics

getUserDemographics

Module: google-analytics | Returns: object -- API response.

google-analytics.getUserDemographics
ParameterTypeRequiredDescription
inputstringNoInput parameter

getConversions

getConversions

Module: google-analytics | Returns: object -- API response.

google-analytics.getConversions
ParameterTypeRequiredDescription
inputstringNoInput parameter

Error Handling

All functions throw on failure. Common errors:

ErrorCause
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)

VersionTagPublished
0.1.1latest1 months ago
Install
$ robinpath add @robinpath/google-analytics

Collaborators

Dumitru Balaban
Dumitru Balaban
@dumitru
View all @robinpath modules
Version0.1.1
LicenseMIT
Unpacked Size4.3 KB
Versions1
Weekly Downloads26
Total Downloads26
Stars0
Last Publish1 months ago
Created1 months ago

Category

productivity