Dynamically Add URL parameters to external URL

We have a campaign with a partner where the flow will be as follows:

  1. Offer displayed on partner site
  2. User clicks through to a landing page on our website (on wix)
  3. User clicks from landing page to register on our application (not on wix)

For tracking purposes, we will receive a value from the partner via the referring URL called “planid”. So, when the user lands on our landing page he URL will be something like:

test.com/partnername?planid=CA

On this landing page will be a link to sign up on a URL like this: app.test.com/register?planid={THIS IS WHERE I WOULD NEED IT TO DYNAMICALLY POPULATE WITH “CA” BASED ON THE PLANID PARAMETER OF THE LANDING PAGE URL}

Very much appreciate any thoughts folks have!

Thanks!

1 Like

Hay David,

Your process to get this result is built of two parts.

  1. read the planid parameter from the page url. You can do that using the wix-location module, namely the query member of it.

  2. set the link using code to the target site with the planid parameter.

should look something like

import wixLocation from 'wix-location';

$w.onReady(() => {
  let planid = wixLocation.query.planid;
  if (planid)
    $w('#ELEMENT_WITH_LINK').link = 
      'http://app.test.com/register?planid=' + planid;
})

Thanks, Yoav! This is very helpful. On an even more basic level, I’ve never added javascript to any pages on our website. Would it be possible to walk me through how to go about adding this code?

Second question, assuming I’ve added the javascript correctly, what URL convention do I use for the element (in this case a call to action button on the wix page) itself?

The following video shows how to code on our platform, among other stuff -
https://www.wix.com/code/home/video-custom-interactions

another video to watch is the working with wix code APIs video on this page -
https://www.wix.com/code/home/videos
note you will need to click the next link a few times to get to this video.

other resources -

Thanks, Yoav. I was able to get this working!