Creating an Affiliate Link from URL Query String


We want to set up affiliate links for which affiliates can get credit if a user comes from their site to ours and purchases our product. Unfortunately HubSpot doesn’t offer this service. We can do it from WordPress but want most initial contact to come through HubSpot. Here is the process we need.

  1. User click on an affiliate ad/link (i.e. www examplesite com?afil=affiliateid) that brings them to our HubSpot site…
  2. User goes through our funnel filling out their name, e-mail, etc. on different forms on each page of the funnel.
  3. At the end if the funnel the user clicks on an “Order Now” button which takes them to our WordPress site which has the affiliate software. This link needs to have the same affiliateID that came from the initial link (i.e. www wordpress examplesite com?afil=affiliateid).

I initially thought that setting a cookie and calling it later would work but HubSpot has made clear to me that they do not allow this with either PHP or Javascript or anything else. Basically, the don’t allow me to code the ability to set a cookie.

I have two ideas left and I need your help!

IDEA 1. Keep the initial URL query string in the URL throughout the process. This means that when then get to the landing page (using an affiliate link), the first button has the query string in it. On the next page, they fill out a form and the submit button for the form has to contain original URL query in it to bring it to the next page. This continues until they get to the page with the “Order Now” link (there are only 3-4 pages in each funnel). That page will still have the original query string in the URL. We could then possibly pull the query string using {{request.query}} and add it to a link to the Wordpress site (maybe with Javascript or HubL since PHP is not allowed).

IDEA 2. Put the query string value into a hidden field on an initial form and use it later. Have a form on all Landing Pages and add the affiliate ID to a hidden field on said form to add the affiliate ID to the user data.This post gave me the idea: Cookie Question. The question here would be if we add the affiliate id to the user from the URL query string via a hidden form field, can we later put that in a link after they have submitted everything in order to send them to the WordPress site and give credit to the affiliate?

Please help me in developing any of these ideas. I should be able to program it but need to know which direction is possible within HubSpot.


Hello, have you found a good solution?
We are working with different affiliate partners too, so I thought it would be great if we could have a unique identifier added, so that the affiliate partners would see which lead has filled out the form.
At this time, discussions occur to determine how a lead converted on our site, so if we could add the emailadress in the conversion, and the affiliate would not only see the timing of the conversion, but also the emailaddress, there would be less discussion.

I’m looking forward to hearing about your solution!
Greetings, Annelies