Can I use a Query String to drive personalized content in Sitecore 7.5?

1.7k Views Asked by At

I'm trying to display personalized content on a page IF I have clicked on a specific link on a specific page. My thought was to have a parameter on the link such as:

<a href="Product-Page/?home=1">Go to product page</a>

Then, on "Product Page", hopefully using the rules engine, check if the parameter home exists in the query string. If so, then display a piece of content.

I can't seem to figure out the best way to do this with Sitecore 7.5. Maybe this is the wrong approach.

2

There are 2 best solutions below

2
On BEST ANSWER

Out of the box in Sitecore 7.5 there is no rule for using the querystring. but you can easily create a rule and use with the personalize feature from Sitecore.

See http://blog.martinmiles.net/post/rules-engine-and-sitecore-personalization-based-on-url-query-string-parameters for a complete description and Example include a link to github with the code https://github.com/MartinMiles/Personalization

1
On

so you would have to have something like this:

        public ActionResult Index(string name)
        {
            Student student = new Student();

            student.Name = "John";

            if (!String.IsNullOrEmpty(Request.QueryString["name"]))
            {
                student.Name = Request.QueryString["name"];
            }

            return View(student);
        }

For this example, my controller is named Test. So if I want to call this method I would do ~/test/index, if I do that the student object will contain the name John, however if I do ~/test/index?name=Denis , I will send an object with the name Denis

Here the name will only change when we pass the query string "name" with a value.