Skip to main content
Best answer

How can I change LinkedIn URL parameters to variables for Airtable?

  • October 22, 2024
  • 3 replies
  • 18 views

Overview

 

I’m using LinkedIn ads to send leads to a landing page. There is a form on that landing page that then will send the data from completed forms to an Airtable database.


I’ve added dynamic URL tracking parameters in LinkedIn and I’m capturing this data as a hidden field in the form on the landing page.

 

Here is my LinkedIn URL tracking parameters

campaign_name={{CAMPAIGN_NAME}}&campaign_group_name={{CAMPAIGN_GROUP_NAME}}&account_id={{ACCOUNT_ID}}&campaign_id={{CAMPAIGN_ID}}&creative_id={{CREATIVE_ID}}&account_name={{ACCOUNT_NAME}}

So my variables are the following: campaign_name, campaign_group_name, account_id, campaign_id, creative_id, and account_name

 

The URL data looks like this https://www.website.com/men-start/?campaign_name=conversions&campaign_group_name=test&account_id=12345&campaign_id=6789&creative_id=123&account_name=emm

 

I want to extract the data for each variable and insert into an Airtable. I’m struggling to get each variable without the variable name in the data to insert into Airtable. I’ve tried creating a step where I use Python to extract the tracking parameters, which gets me closer. But the output is a dictionary which doesn’t work in my final step to map and insert the data into my Airtable.

 

Step 1

Gravity Forms Submitted. This step works great and I capture the URL with my LinkedIn tracking parameters along with the other form data.

 

Step 2 Python Code (Keep or Change?)

from urllib.parse import urlparse, parse_qs

# Function to extract tracking parameters
def extract_tracking_parameters(url):
    # Parse the URL and extract query parameters
    parsed_url = urlparse(url)
    query_params = parse_qs(parsed_url.query)

    # Define the keys to extract
    keys = ["campaign_name", "campaign_group_name", "account_id", "campaign_id", "creative_id", "account_name"]

    # Loop through the keys and print their values or "null" if missing
    for key in keys:
        value = query_params.get(key, ["null"])[0]
        print(f"{key}: {value}")

# Sample URL
url = "https://www.website.com/men-start/?campaign_name=conversions&campaign_group_name=test&account_id=12345&campaign_id=6789&creative_id=123&account_name=emm"

# Extract and print the tracking parameters
extract_tracking_parameters(url)

The dictionary that is created as output is this from testing: campaign_name: conversions,campaign_group_name: test,account_id: 12345,campaign_id: 6789,creative_id: 123,account_name: emm

 

Final Step

 

Mapping data to my Airtable database isn’t possible without some formatting steps in-between to extract the variable data and send each piece into fields for Campaign Name, Account Id, etc. I tried some formatter steps, but I’m still not getting it. I don’t want the data to be “campaign_name: conversions” (from the example above), but instead just be “conversions”.

 

How can I extract the data from the URL and make each piece of information separate in prior steps so I can insert the info into my Airtable without the name of the variable in the text?

Best answer by Troy TessaloneBest answer by Troy Tessalone

Hi @Marketing Automations 

Try this guide:

 

View original
Did this topic help you find an answer to your question?
This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

3 replies

Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 31575 replies
  • Answer
  • October 22, 2024

Hi @Troy Tessalone thanks for the quick response and specific solution. It works perfectly!


SamB
Community Manager
Forum|alt.badge.img+11
  • Community Manager
  • 7906 replies
  • October 23, 2024

Yay! Really pleased that guide Troy shared did the trick, @Marketing Automations. Thanks so much for writing and sharing it, @Troy Tessalone! 🙌

Sounds like you’re all set so I’ll get Troy’s reply marked as the best answer to better surface this information to others. If there’s anything else we can help with please do reach back out to the Community. In the meantime, happy Zapping! ⚡