Dynamic content based on URL parameter | Community
Skip to main content
September 30, 2015
Question

Dynamic content based on URL parameter

  • September 30, 2015
  • 4 replies
  • 6083 views

Has anyone used a URL parameter to call dynamic content in a Marketo landing page?

example - abc.com?companyname=123

Content displayed = 123 logo

My use case is:

I want to send a link with a company name embedded in a url so I can customize the landing page with companies logo.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

4 replies

SanfordWhiteman
Level 10
September 30, 2015

Sure, in fact you can pass a segment identifier in the URL.

     example.com?brand=123Co

will display the page as if the person were in the segment "123Co" of segmentation "brand."

September 30, 2015

I should have stated that we won't know the visitor. Our affiliate marketers will send these links to there channels and drive them to a landing page that we host in Marketo and customized for them with an embedded form. I would like to create 1 dynamic landing page rather then many static pages.

SanfordWhiteman
Level 10
September 30, 2015

I don't see how not knowing the visitor matters, unless you are planning to pass the full URL to the affiliate's logo in the query string (thus your Marketo instance doesn't have to know anything about the affiliate).

Anyway, the segment trick is just a shortcut. Any other customization based on URL is basic HTML/CSS/JS stuff. It's as possible with Mkto LPs as with any other webpage.

March 2, 2016

Hi Jason,

I was just wondering if you ever got this to work? We want to do something similar and use a URL parameter to pull dynamic content on our landing pages. We have several different pages for companies we work with and instead of having to create unique pages for each company, we want to use vanity urls that direct to one dynamic landing page.

We would pass their company name in the URL and display their name on the page. For example, welcome XYZ company employee.

Any help or advice on this would be great! Thanks!

March 2, 2016

Hi Carly,

We changed direction and the project got put on the back burner. But if you follow Sanford's posts above you should be able to trigger dynamic content by using the segmentation trick.

Robb_Barrett
Level 10
March 7, 2016

This might help:

The first function will pull down the value of any URL parameter you request.

function getUrlParameter(sParam)

{

    sPageURL=window.location.search.substring(1);

    var sURLVariables = sPageURL.split('&');

    for (var i = 0; i < sURLVariables.length; i++)

    {

       var sParameterName = sURLVariables[i].split('=');

       if (sParameterName[0].toLowerCase() == sParam.toLowerCase())

           return sParameterName[1];

    }

    return "";

}

var company = decodeURI(getUrlParameter("company")); //*this removes the HTML codes

function getCompanyLogo(compName) { 

var image=""; 

if (/[?&]campaignID=/.test(location.href) == false)  {  //*this tests to see if the parameter exists

    image = "path-to-default.com/image.jpg";  //*use default image

  } else {

  if (compName== "company1") {

     image = "path-to-image.com/company1.jpg";

} else {

     if(compName== "company2") {

     image = "path-to-image.com/company1.jpg";

} else {

....

}  //*close company name loop

} //*close top level test

return image; //*sends back the correct URL

var image = document.createElement("img");  //*create an image DOM
image.setAttribute("src", getCompanyLogo(company)); //*Set the image as the URL selected
document.getElementById("your-empty-div").appendChild(image); //*Put the image in the DIV

Robb Barrett
SanfordWhiteman
Level 10
March 7, 2016

Robb, you don't need any JS for a dynamic (temporary) segmentation. The URL is parsed on the server.

(Also, that JS will break on some well-formed URLs, but that's another issue.)

Ronen-Was-SRpro
Level 5
April 10, 2019

Hi,

Is it possible to show a form in a landing page that will be changed to different languages according to the URL? For example, if the user has www.goog.com/EN

He will be shown the form in English or if the user has www.goog.com/ES he will see the same form in Spanish.

Thank you.

Ronen Wasserman
SanfordWhiteman
Level 10
April 10, 2019

The question is more about whether a single form can dynamically change languages at all. And the answer is: it can't, unless you use the Forms API (we've done this to create a single internationalized form, but it's not simple).

If you have multiple forms (different Form IDs) already separated by language, then Yes: that can be part of Dynamic Content and in turn can be selected by passing ?{Segmentation}={Segment} in the URL.