Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

better-attribution

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

better-attribution

Track first and last attr

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
340
decreased by-15.21%
Maintainers
1
Weekly downloads
 
Created
Source

better-attribution

npm version npm downloads

Using this package

import { betterAttribution, DefaultQueryParams } from "better-attribution";

const { storeAttributionValues, getLastTouch, getFirstTouch } =
  betterAttribution();

// Stores the current URL query params and referrer in a cross site cookie
storeAttributionValues();

// Retrieves an object of the query params and referrer from the latest visit
const lastParams = getLastTouch();

// Retrieves an object of the query params and referrer from the first visit
const firstParams = getFirstTouch();

// optional arguments:
betterAttribution({
  // allows tracking of additional (or fewer) query params
  queryParams: [...DefaultQueryParams, "custom_known_query_param"],
  // allows prefixing the cookie w a custom string
  cookiePrefix: "custom_prefix",
  // allows setting the cookie w a custom domain
  domain: "example_2.com",
});

Features:

  • Uses cookies to store visitors query params and the referrer for attribution tracking
  • Exposes methods to retrieve the last and first touch attribution data
  • Allows you to override collected query params
  • Allows you to submit to your analytics platform or on form submissions additional info about how the user found your site for the first and most recent time.
  • Enables MMM (marketing mix modeling) // MTA (multi-touch attribution)
  • Tracks the document referrer

Default list of tracked query params (you can override this in the setup function):

  • utm_source
  • utm_medium
  • utm_campaign
  • utm_content
  • utm_name
  • utm_term
  • fbclid
  • ad_id
  • gclid
  • gc_id

Install

npm i better-attribution

License

MIT

FAQs

Package last updated on 08 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc