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"
}
/*