Insights
Contact Us

Apr 9, 2025

Using First-Party Cookies To Store Campaign Parameters

If you don't have a CDP and don't want to use a database, this approach will allow you to pass accurate campaign data to your CRM.

If you're a marketer focused on lead generation, you're adding parameters to links in campaigns to track campaign performance. If a user clicks one of your links and then completes a form on your site, those campaign parameters need to be passed through to your CRM.

Because my audience is marketers I've written this as simply as possible. Even if you have a primitive understanding of JavaScript, I think you'll be able to follow along.

URL Parameter Examples

Below is an example of a URL that might be created to track a specific campaign. This URL contains the standard UTM parameters but you can also use custom parameters.


Below is an example of a URL with custom parameters.

Capturing Parameters

Using vanilla Javascript, we're going to make use of the URLSearchParams utility. This is a JavaScript constructor that provides a lot of helpful methods for manipulating data

// get query string from url
const paramsString = window.location.search;

// create a new URLSearchParams object
const params = new URLSearchParams(paramsString);

Table of Contents

demand stack logo
We Build Amazing Websites That Amplify Your Marketing and Accelerate Business Growth
14309 Larsen St
Overland Park, KS 66221

Website Services

Web Design & DevelopmentEcommerce DevelopmentPayload CMS Webflow CMSStrapi CMS

Demand Stack, All Rights Reserved 2025