4

The marketing platform I am using is adding a query string to my page Urls. Here's an example how it is adding the string to my index.html:

https://www.example.com/index.html?SessionGuid=5365jh-49eb-2547-9865-b4c34aed8c94

I have these anchor links in the main navigation, they jump up and down the page to different sections, here's an example:

<a class="nav-link" href="#rankings">Rankings</a>

Now when the nav link is clicked, the page jumps to the correct area but the query string is getting removed from the URL and the Url changes to this:

https://www.example.com/index.html#rankings

But the # should be added at the end of the Url and the Url should look like this:

https://www.example.com/index.html?SessionGuid=5365jh-49eb-2547-9865-b4c34aed8c94#rankings

What am I missing? Why does the # click remove the ?SessionGuid= query string in the Url?

hnnnng
  • 481
  • 4
  • 21
  • Does this answer your question? [Add Query-String parameter to static link on click](https://stackoverflow.com/questions/25290299/add-query-string-parameter-to-static-link-on-click) – kennyvh Apr 26 '21 at 21:25
  • 1
    I'm unable to reproduce this with a local html file. Could you maybe add some more details about how the site is hosted? Maybe even a CMS? – 0stone0 Apr 26 '21 at 21:25
  • Which browser is this? I tried FF and Chrome and both added the `#foo` after the search params. – ggorlen Apr 26 '21 at 21:26
  • @khuynh thanks for the dupe request but I don't think that's what OP wants. – ggorlen Apr 26 '21 at 21:27
  • @khuynh the JS method can be an option, thanks. I'll try and see if I can fix it without JS first. – hnnnng Apr 26 '21 at 21:35
  • @0stone0 the marketing platform is Mindfire. The pages are static, the platform is basically adding additional tracking info to the page. I think it has something to do with the way and time the query string is being added to the Url. When I refresh the page (after the nav click removes the string) then the page reloads correctly and the Url structure looks fine with the query string and the hash added at the end – hnnnng Apr 26 '21 at 21:39
  • I've also faced this situation, on most web pages a href beginning with a hashtag does not reload the page, but scrolls to the content, on some odd pages, they are reloading the page, and with removed query params, the question is if a relative url #aaaa to a base url of example.com?aaa=1 is example.com?aaa=1#aaaa or example.com#aaaa, when this happens chrome and FF are the same – Sam Washington Jul 14 '22 at 19:58

0 Answers0