@bufferapp/utms

0.1.0 • Public • Published

Buffer's UTM extracting helper fuctions

This module offers some basic logic to extract UTM parameters from the query string. It returns them in a simple data structure that includes a TTL so that we can define when to discard the found UTM parameters

This module is currently shared between buffer-login and buffer-marketing to handle UTM tracking in a consistent way

Install

npm install @bufferapp/utms --save

Usage

The main API to this module is refreshUtms(query, previousUtms), it takes the curret query parameters (object) and the previous value returned by this function (which includes both the extracted UTMs and the TTL info)

This package does not take care of storing previous UTMs, a simple way to use it is by storing them in the users session:

const { refreshUtms } = require('@bufferapp/utms')

middleware.trackUtm = (req, res, next) => {
  req.session.utms = refreshUtms(req.query, req.session.utms)

  next()
}

With the above middleware, the currently valid UTMs for the request would be available in req.session.utms.values

Readme

Keywords

none

Package Sidebar

Install

npm i @bufferapp/utms

Weekly Downloads

68

Version

0.1.0

License

ISC

Unpacked Size

6.27 kB

Total Files

7

Last publish

Collaborators

  • davidluhr
  • egomezd
  • jacobchadwell
  • philippemiguet
  • josemdev
  • msanroman
  • daisymarie128
  • hamstu
  • stevenc81
  • bufferbot
  • mayauribe
  • esclapes
  • ay8s
  • mickmahady
  • dinostheo
  • hitherejoe
  • dace
  • erickhun
  • kmbriseno
  • kiriappeee
  • cmunozgar
  • peteremilbuffer
  • arekpn
  • abeeb
  • buffermw