How to Extract URL Query Parameters Into Variables

Problem Statement

You have a URL that has query parameters, e.g.:

https://example.com/confirm?wj_lead_email=324234gersonr123fr567756576567%40gmail.com&wj_lead_first_name=gersonpublis1123234hing3&wj_lead_last_name=&wj_lead_phone_country_code=&wj_lead_phone_number=&wj_room_password=&wj_lead_unique_link_live_room=https%3A%2F%2Fevent.webinarjam.com%2Fgo%2Flive%2F182%2Fnk2yyan9bnvu173a7v6&wj_event_ts=1722553200&wj_event_tz=America%2FSao_Paulo&wj_next_event_date=quinta-feira%2C+01+agosto+2024&wj_next_event_time=8%3A00+PM&wj_next_event_timezone=Rio+de+Janeiro%2C+Sao+Paulo+GMT+-3

You want to extract each query parameter pair into variables like this:

wj_lead_first_name → gersonpublis1123234hing3
wj_event_ts → 1722553200
wj_event_tz → America%2FSao_Paulo
etc.

Solution

You’ll need a minimum of a single module:

Screenshot_2024-08-02_090804

Screenshot_2024-08-02_090848

Explanation

  1. Remove the hostname and path of the URL. This can be done using the replace function.

    Screenshot_2024-08-02_090847

    This will leave the following part of the URL:

    wj_lead_email=324234gersonr123fr567756576567%40gmail.com&wj_lead_first_name=gersonpublis1123234hing3&wj_lead_last_name=&wj_lead_phone_country_code=&wj_lead_phone_number=&wj_room_password=&wj_lead_unique_link_live_room=https%3A%2F%2Fevent.webinarjam.com%2Fgo%2Flive%2F182%2Fnk2yyan9bnvu173a7v6&wj_event_ts=1722553200&wj_event_tz=America%2FSao_Paulo&wj_next_event_date=quinta-feira%2C+01+agosto+2024&wj_next_event_time=8%3A00+PM&wj_next_event_timezone=Rio+de+Janeiro%2C+Sao+Paulo+GMT+-3

  2. Split by the parameter delimiter &

    Screenshot_2024-08-02_090858

  3. Join by newline. This is because the Text Parser “Match Elements” module works with newlines.

    Screenshot_2024-08-02_090811

    This will result in the following text:

    wj_lead_first_name=gersonpublis1123234hing3
    wj_lead_last_name=
    wj_lead_phone_country_code=
    wj_lead_phone_number=
    wj_room_password=
    wj_lead_unique_link_live_room=https%3A%2F%2Fevent.webinarjam.com%2Fgo%2Flive%2F182%2Fnk2yyan9bnvu173a7v6
    wj_event_ts=1722553200
    wj_event_tz=America%2FSao_Paulo
    wj_next_event_date=quinta-feira%2C+01+agosto+2024
    wj_next_event_time=8%3A00+PM
    wj_next_event_timezone=Rio+de+Janeiro%2C+Sao+Paulo+GMT+-3
    
  4. Finally, let the Text Parser Match Elements module split the parameters by =

    Screenshot_2024-08-02_090848 - Copy

Hope this helps! Let me know if there are any questions or issues.

You can also join us in the Make Fans Discord server to chat with other makers. Due to the evolving needs of this community, the Discord invite link can be found elsewhere on this forum. You can either search for it or post below to request an invite.

4 Likes

Example Output

Screenshot_2024-08-02_090851

Mapping of Variables (optional)

If you want to make it easier to map these variables, you can aggregate to an array:

Then, use a Set Variable module to convert into a collection, using the toCollection built-in function:

Screenshot_2024-08-02_090842

Screenshot_2024-08-02_090859

Hope this helps! Let me know if there are any further questions or issues.

— @samliew

3 Likes

This is amazing! Thanks! I’m new to Make, how do I configure my page to let this automation run? I think I can follow your steps in Make, but what do I need to do in my page to make this work? TIA

I think that my question comes down to how can I trigger all of this?

Put the URL into the text parser, shown in the screenshot in the first post, as the variable “Text”.