1

I have a query string on a thank you page like this:

mysite.com/ty-page?querystring=12345abcde

On this thank you page, there's a CTA button, (from the standard hero item). This button links to another page and I would like the querystring from the URL (name and value) to the link in the CTA.

So the link should look like this when setting it up:

mysite.com/page2

And when you get to the TY page, if this querystring is in the URL it should add the querystring so the CTA link is:

mysite.com/page2?querystring=12345abcde

Picture below for clarification on where the query string is entered.

1
  • You can do code to read querystring from URL and merge query string in CTA URL Commented Aug 17, 2019 at 9:01

2 Answers 2

1

It will go in Query String field. In order to fetch it you need to write something like this

or

@using (Html.Glass().BeginRenderLink(navItem, x => x.Link, new { @class = cssClass })) { @Html.Glass().Editable(navItem, x => x.Title); }

or

Link.Url+"?"+Link.Query

for more refer below link: Glass mapper BeginRenderLink stripping query string parameter that is a Url with ga parameters

0

In the component where you have the CTA button write the code as:

In c#

string key = "querystring";
  if (!string.IsNullOrEmpty(Request.QueryString[key]))
    {
      <a href="@string.Format("http://domain.com/{0}={1}", "?" + key, Request.QueryString[key])">GO to page2</a>
    }
  else
    {
      <a href="http://domain.com" >GO to page2</a>
    }

If you want to handle it with jQuery then:

  1. get the query string value using jQuery ( you can do it as suggested here: https://stackoverflow.com/questions/4656843/jquery-get-querystring-from-url)

  2. Check if the query string value is not null, empty or undefined.

  3. Provide id or class on your CTA link, so that bu the reference of id or class CTA's href attribute can be filled with the complete page url + query string value retrieved in step-1.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.