Quick start

Installation

yarn add @distributed/utm
npm install @distributed/utm

Usage

Without any parameter

Given the existing url location: https://example.com/?utm_source=google&utm_campaign=campaignName&utm_medium=medium&utm_content=content&utm_term=term

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

const utms = utm();

console.table(utms);

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

With parameter

Given the existing url location: https://example.com/?utm_source=google&utm_campaign=campaignName&utm_medium=medium&utm_content=content&utm_term=term

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"
}
/*
Edit this page on GitHub Updated at Fri, Aug 26, 2022