Personalize Your WordPress Website Based on Ad Campaigns (No Plugins Needed!)
Boost conversions by dynamically personalizing your WordPress website based on ad campaigns—without plugins! Learn how to use PHP and UTM parameters to deliver a tailored experience and increase engagement.

Personalize Your WordPress Website Based on Ad Campaigns (No Plugins Needed!)
Imagine you run a travel website offering deals on luxury hotels, adventure tours, and budget-friendly vacations. You're investing in Google Ads, bringing visitors to your site with keywords like "best 5-star hotels" or "cheap flights under $200".
But here's the problem
Every visitor lands on the same generic page.
Wouldn't it be better if someone searching for "adventure vacations" automatically saw content about thrilling mountain treks and extreme sports packages, while someone searching for "luxury resorts" saw a homepage featuring 5-star beach resorts?
✅ This creates a personalized experience.
✅ It increases conversions.
✅ And you can do it without plugins!
Why Do This Without a Plugin?
Most WordPress users rely on plugins for dynamic content personalization, but using PHP gives you:
✔ Faster performance - No bloated plugins slowing down your site.
✔ More control - Customize the experience exactly as you need it.
✔ No compatibility issues - No conflicts with Elementor or other page builders.
Now, let's implement keyword-based content personalization in WordPress - without plugins.
How It Works
When a user clicks on an ad, the URL contains tracking parameters like:
https://yoursite.com/?utm_source=google&utm_term=luxury+resorts
From this URL, we extract the utm_term (the keyword) and dynamically map it to the right travel category.
For example:
- "luxury resorts" - Show content about Luxury Hotels
- "budget travel tips" - Show content about Affordable Hotels
- "adventure vacations" - Show content about Extreme Adventure Tours
Now, let's code this!
Step 1: Add PHP Code to Your functions.php File
This PHP function:
- Reads the keyword or utm_term from the URL
- Maps it to a travel category
- Displays the correct category name via a shortcode
<?php
function mm_utm_keyword_to_adgroup($atts) {
// Get utm_term from URL
$utm_term = isset($_GET['utm_term'])
? strtolower(sanitize_text_field($_GET['utm_term']))
: '';
// Map keywords to ad groups / content categories
$keyword_to_adgroup = [
'luxury resorts' => 'Luxury Hotels',
'luxury hotels' => 'Luxury Hotels',
'best 5-star hotels' => 'Luxury Hotels',
'adventure vacations' => 'Adventure Tours',
'extreme sports' => 'Adventure Tours',
'budget travel' => 'Budget Travel',
'budget travel tips' => 'Budget Travel',
'cheap flights' => 'Budget Travel',
];
// Return matched category or default fallback
foreach ($keyword_to_adgroup as $keyword => $adgroup) {
if (strpos($utm_term, $keyword) !== false) {
return esc_html($adgroup);
}
}
return 'Discover Amazing Travel Deals';
}
add_shortcode('mm_utm_keyword_to_adgroup', 'mm_utm_keyword_to_adgroup');
?>
Step 2: Use the Shortcode in WordPress
Simply place this shortcode anywhere in WordPress to display personalized content:
[mm_utm_keyword_to_adgroup]
Where to place it?
✅ Inside blog posts and pages
✅ In Elementor text widgets
✅ Inside headers or call-to-action sections
Step 3: Test Your Setup
Example 1: Luxury Hotels Visitor
URL: https://yoursite.com/?utm_term=luxury+resorts
What they see: "Luxury Hotels"
Example 2: Budget Traveler
URL: https://yoursite.com/?utm_term=budget+travel+tips
What they see: "Budget Travel"
Example 3: No UTM Keyword
URL: https://yoursite.com/
What they see: "Discover Amazing Travel Deals" (default fallback text)
Bonus: Improve Conversions with a CTA
Since we're personalizing content, let's also add a high-converting call-to-action (CTA).
HTML for a CTA Block
<div class="travel-cta">
<h3>Looking for the Best <span>[mm_utm_keyword_to_adgroup]</span>?</h3>
<p>We have exclusive offers just for you. Don't miss out.</p>
<a href="#lead-form" class="cta-button">Get Your Exclusive Offer</a>
</div>
Final Thoughts
With just a few lines of PHP, you've transformed your WordPress site into a personalized experience.
✅ Visitors see exactly what they searched for.
✅ Your conversion rate improves because content feels more relevant.
✅ No heavy plugins, just clean and efficient PHP code.
Want to take this further?
- Dynamically change headlines, CTAs, and images
- Use JavaScript to instantly update content without refreshing the page
- Track conversions with Google Analytics and heatmaps
Senior PM and UX Expert with 9 years of experience shipping products across fintech, ed-tech, ecommerce, and government sectors. Leads UX and development at YAMU Media and runs MediaMen Services.
aanandmadhav.com →