New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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 - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

22

dist/index.d.ts
declare const DefaultQueryParams: string[];
declare const betterAttribution: (opts?: {
interface BetterAttribution {
/**
* A list of query params to store from the url
* You can import {DefaultQueryParams} from 'better-attribution' if you'd like to add onto our list.
*
* @example [... DefaultQueryParams, 'utm_source', 'utm_medium', 'utm_campaign']
**/
queryParams?: string[];
/**
* A prefix to add to the cookie keys. This is useful if you want to use this library multiple times.
* The first and last touch keys will be prefixed with this value.
* @example bobs_widgets becomes bobs_widgets_first_touch
*/
cookiePrefix?: string;
/**
* The domain to set the cookie on. Defaults to the current domain.
* @example .example.com
**/
domain?: string;
}) => {
}
declare const betterAttribution: (opts?: BetterAttribution) => {
firstTouchKey: string;

@@ -15,2 +31,2 @@ lastTouchKey: string;

export { DefaultQueryParams, betterAttribution };
export { BetterAttribution, DefaultQueryParams, betterAttribution };

15

package.json
{
"name": "better-attribution",
"version": "1.0.1",
"description": "Track first and last attr",
"version": "1.0.2",
"description": "Allows you to easily tracks & store first/last touch attribution in cookies to enable multi-touch attribution. Tracks UTMs, Facebook, Google Ads, and more automatically.",
"publishConfig": {

@@ -11,2 +11,9 @@ "access": "public"

],
"keywords": [
"attribution",
"first touch",
"last touch",
"utm tracking",
"attribution cookie tracking"
],
"repository": {

@@ -33,5 +40,5 @@ "type": "git",

"@types/js-cookie": "^3.0.3",
"prettier": "3.0.3",
"tsup": "7.2.0",
"typescript": "5.2.2",
"prettier": "3.0.3",
"vitest": "0.34.4"

@@ -42,2 +49,2 @@ },

}
}
}

@@ -10,23 +10,14 @@ # better-attribution

const { storeAttributionValues, getLastTouch, getFirstTouch } =
betterAttribution();
const attr = betterAttribution();
// Stores the current URL query params and referrer in a cross site cookie
storeAttributionValues();
attr.storeAttributionValues();
// Retrieves an object of the query params and referrer from the latest visit
const lastParams = getLastTouch();
// JSON from the latest visit
const lastParams = attr.getLastTouch();
console.log(lastParams); // {referrer: 'facebook.com', fbclid: 'abc-123'}
// 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",
});
// JSON from the first visit
const firstParams = attr.getFirstTouch();
console.log(lastParams); // {utm_term: 'first-visit-term', referrer: 'google.com'}
```

@@ -56,2 +47,16 @@

Customization:
```js
// All arguments are optional
const attr = 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",
});
```
## Install

@@ -58,0 +63,0 @@

Sorry, the diff of this file is not supported yet

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