channel-grouping is a marketing channel attribution and referrer parsing (UTM) client-side library written in Javascript. It uses Google Analytics Default Channel Definitions to attribute traffic on your site to specific channels.
npm install --save channel-grouping
yarn add -s channel-grouping
When Landing Page UTM Medium matches Regex /^email$/i
When Landing Page UTM Medium matches Regex /^affiliate$/i
When Landing Page UTM Medium matches Regex /^referral$/i
When Landing Page UTM Medium matches Regex /^(organic|search)$/i
When Landing Page UTM Medium matches Regex /^(cpc|ppc|paidsearch)$/i
When Landing Page UTM Medium matches Regex /^(cpv|cpa|cpp)$/i
When Landing Page UTM Medium matches Regex /^(display|cpm|banner)$/i
When Landing Page UTM Medium matches Regex /^(social|social-network|social-media|sm|social network|social media)$/i
When Landing Page or Referrer has no UTM Source
When Landing Page Hostname and Referrer Hostname are the same
All other cases, while UTM Medium does not equal (none)
import { Attribution } from "channel-grouping";
const ChannelGroup = Attribution.analyze(document.referrer, window.location.href);
console.log(ChannelGroup);
{
campaign: ""
channelGroup: "Direct"
content: ""
landingPageDomain: "http://localhost:3001"
medium: "(none)"
referrerDomain: "",
source: "(direct)",
term: ""
}