Pulling and Replacing URL Parameters in Radiant CMS

255 Views Asked by At

I am trying to pull url parameters from AdWords and replace them on the landing page content using Ruby on Rail Radiant CMS.

For example if the URL from AdWords was: www.example.com/?keyword={keyword}&{copy:matchype}

I want to pull out {keyword} on the landing page that says something like :

"Looking for {keyword}? we can help?"

I think this is possible using something like:

<% if params[:keyword] %>
Looking for "<%= params[:utm] %>"? we can help
<% end %>

Some help would be great.

Thanks

2

There are 2 best solutions below

2
On

That's easy:

<% if params[:keyword] %>
Looking for "<%= params[:keyword] %>"? we can help
<% end %>

In a nutshell: if the keyword is present as a parameter, then display it with the desired text.

0
On

You can use the if_param_tags extension for this. With that in place, you could write:

<r:if_param name="keyword">
  Looking for "<r:param name="keyword"/>"? we can help
</r:if_param>