Overview
I'm utilizing LinkedIn ads to direct leads to a landing page. This landing page features a form that subsequently transmits completed form data to an Airtable database.
I've incorporated dynamic URL tracking parameters within LinkedIn and am capturing this data as a hidden field in the landing page's form.
Here are 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}}
Therefore, my variables are as follows: campaign_name, campaign_group_name, account_id, campaign_id, creative_id, and account_name.
The URL data appears 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
My objective is to extract the data for each variable and populate my Airtable. I'm encountering difficulties in isolating each variable's value without the variable name itself for insertion into Airtable. I've attempted to create a step using Python to extract the tracking parameters, which gets me closer. However, the output is a dictionary, which doesn't work in my final step for mapping and inserting the data into my Airtable.
Step 1
Gravity Forms Submitted. This step functions correctly, and I successfully capture the URL with my LinkedIn tracking parameters along with 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 generated as output from testing is: 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 is not feasible without intermediate formatting steps to extract the variable data and send each piece into fields for Campaign Name, Account Id, etc. I've tried using some formatter steps, but I'm still not succeeding. I need the data to be just "conversions" rather than "campaign_name: conversions" (as shown in the example).
How can I extract the data from the URL and format each piece of information into separate values in prior steps so that I can insert the information into my Airtable without the variable names included?
Hi
Please try this guide:
Hi, thanks for the quick response and specific solution. It works perfectly!
Great! Really glad the guide that was shared was helpful. Thanks so much for writing and sharing it! 🙌
It sounds like you're all set, so I'll mark the reply as the best answer to make this information more visible to others. If there's anything else we can assist with, please feel free to reach out to the Community again. In the meantime, happy callin.io-ing! ⚡