Skip to content

A Google Analytics validator for query params with NodeJS

License

Notifications You must be signed in to change notification settings

tshaddix/ga-validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Google Analytics Validator

Google Analytics validator for NodeJs. Easily validate Google Analytics query parameters. It is used extensively in our OOcharts app.

##Usage##

Install gav through npm: npm install ga-validator

gav = require('ga-validator');

//Do stuff...

##Methods##

###getDimension(dim)###

Gets a dimension by GA value.

Arguments

  • dim - A string GA value of form ga:value

Example

gav.getDimension('ga:browser'); //returns { value : 'ga:browser', name : 'Browser', regex : RegExpObject }

###getMetric(met)###

Gets a metric by GA value.

Arguments

  • met - A string GA value of form ga:value

Example

gav.getMetric('ga:visits'); //returns { value : 'ga:visits', name : 'Visits', regex : RegExpObject }

###checkDimension(dim)###

Checks whether a dimension is valid.

Arguments

  • dim - A string GA value of form ga:value

Example

gav.checkDimension('ga:browser'); //returns true
gav.checkDimension('ga:bad'); //returns false

###checkMetric(met)###

Checks whether a metric is valid.

Arguments

  • met - A string GA value of form ga:value

Example

gav.checkMetric('ga:visits'); //returns true
gav.checkMetric('ga:bad'); //returns false

###checkSort(sort)###

Checks whether a sort value is valid.

Arguments

  • sort - A string GA sort value

Example

gav.checkSort('-ga:visits'); //returns true
gav.checkSort('ga:visits'); //returns true

###checkSegment(seg)###

Checks whether a segment value is valid.

Arguments

  • seg - A string GA segment value

Example

gav.checkSegment('gaid::10'); //returns true
gav.checkSegment('dynamic::ga:medium==referral'); //returns true

###checkFilter(filter)###

Checks whether a filter value is valid.

Arguments

  • filter - A string GA filter value

Example

gav.checkFilter('ga:visits>10;ga:country==Canada'); //returns true

About

A Google Analytics validator for query params with NodeJS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published