Skip to content

distributedvc/utm

Repository files navigation

preview

Build Status npm version Dependencies npm downloads code style: prettier License: MIT

Small library to parse utm parameters.

Install

With yarn:

yarn add @distributed/utm

With npm:

npm install @distributed/utm

Usage

import { utm } from '@distributed/utm';

// location.search => ?utm_source=google&utm_campaign=campaignName&utm_medium=medium&utm_content=content&utm_term=term
const utms = utm(location.search);

console.table(utms);

/* =>
{
  "utm_source": "google",
  "utm_campaign": "campaignName",
  "utm_medium": "medium",
  "utm_content": "content",
  "utm_term": "term"
}
/*

Try it live

curl "https://utm.distributed.sh/?utm_source=google&utm_campaign=campaignName&utm_medium=medium&utm_content=content&utm_term=term"

# =>
# {
#   "utm_source": "google",
#   "utm_campaign": "campaignName",
#   "utm_medium": "medium",
#   "utm_content": "content",
#   "utm_term": "term"
# }

Development

  1. Install dependencies using yarn install or npm install
  2. Start development server using yarn watch

📑 License

MIT License