2.0.0 • Published 8 years ago

@segment/utm-params v2.0.0

Weekly downloads
20,283
License
SEE LICENSE IN LI...
Repository
github
Last release
8 years ago

utm-params

CircleCI Codecov

Parse a URL, returning all UTM parameters.

Installation

$ npm install @segment/utm-params

API

utm(querystring : string)

utm('?utm_source=google&utm_medium=medium&utm_term=keyword&utm_content=some%20content&utm_campaign=some%20campaign&utm_test=other%20value');
{
  "source": "google",
  "medium": "medium",
  "term": "keyword",
  "content": "some content",
  "name": "some campaign",
  "test": "other value"
}

###utm.strict(querystring : string)

Will only return the 5 Google Analytics spec'd utm params

utm.strict('?utm_source=google&utm_medium=medium&utm_term=keyword&utm_content=some%20content&utm_campaign=some%20campaign&utm_test=other%20value');
{
  "source": "google",
  "medium": "medium",
  "term": "keyword",
  "content": "some content",
  "name": "some campaign"
}