Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect Manager: Combining redirect query parameters with external query parameters #3509

Open
juliaetate opened this issue Jan 15, 2025 · 5 comments
Assignees

Comments

@juliaetate
Copy link

juliaetate commented Jan 15, 2025

AEM As a Cloud Service: Adobe Experience Manager 2024.11.18751.20241128T090041Z
ACS AEM Commons Version: 6.5.0

When we have a redirect set up with a query parameter in the destination URL and go to the URL on our AEM instance, the query parameter works fine. When this redirected URL is posted to social media where site-specific tracking is added to the URL such as Facebook adding the fbclid parameter, the query parameter within the Redirect Manager is not maintained but the fbclid parameter is. If we turn off Preserve Query String, then the query parameter within the Redirect Manager is maintained but the fbclid is lost.

When a page is created within AEM with a redirect, and that page's URL is shared to social media such as Facebook, the fbclid is appended to the link. When the redirect occurs, the redirected URL contains both the parameter from the redirect URL AND the additional parameters from the initial URL clicked. If the vanity URL https://www.domain.com/redirect points to https://www.domain.com?a=1&b=2 and then https://www.domain.com/redirect is posted to Facebook where fbclid is appended, then the destination URL becomes https://www.domain.com?a=1&b=2&fbclid=xyz.

With the redirect manager, we can either get https://www.domain.com?a=1&b=2 OR https://www.domain.com?fbclid=xyz depending on the status of preserveQueryString.

Is there any way to have the redirect manager merge the two query parameters like an AEM redirect page rather than having to choose between the redirect query parameters or the incoming query parameters?

Through the dispatcher, if a destination URL has a query parameter, that is used instead of an incoming one. Even that behavior would be preferable with preserveQueryString enabled. If https://www.domain.com/page.html redirects to https://www.domain.com?a=1&b=2 but the external link has a query parameter appended such as https://www.domain.com/page.html?fbclid=xyz, we would prefer to see the final destination have the defined destination parameters instead of the external one, ie https://www.domain.com?a=1&b=2, if they cannot be merged the way a page redirect would work.

@YegorKozlov YegorKozlov self-assigned this Jan 18, 2025
@YegorKozlov
Copy link
Contributor

YegorKozlov commented Jan 18, 2025

@juliaetate Good point - there's definitely room for improvement here.

Firstly, I'd like to move preserveQueryString to the redirect configuration dialog, so that it can specified per-redirect instead of the OSGi configuration.
This settng can be a drop-down with three options:

  • ignore
  • replace (default, matching current implementation)
  • merge (combines query string in the target with query string in the request, as you proposed)

It'll see what I can do.

BTW, there is a related thing: in the current implentation preserveQueryString drops URI fragments, for example, you'd setup

/legacy => /new-target#top

and then a request with a query string will drop the fragment, e.g.

/legacy?fbclid=blah => /new-target?fbclid=blah

I'd say the fragment should be preserved and the redirect should be

/legacy?fbclid=blah => /new-target?fbclid=blah#top

The PR is coming soon.

@juliaetate
Copy link
Author

@YegorKozlov Moving the option to the redirect screen is interesting, but I would love to also see the merge option as part of the OSGi configurations if that's possible. With potentially thousands of redirects managed by multiple different people, having to remember to manually change a setting each time could lead to user errors unless there's a better control on the default.

@YegorKozlov
Copy link
Contributor

@juliaetate the OSGi flag needs to be boolean for compatibility reasons. We can't turn it into a drop-down.

I'm fine to change the default behavior to merge query strings though.

YegorKozlov added a commit to YegorKozlov/acs-aem-commons that referenced this issue Jan 22, 2025
@juliaetate
Copy link
Author

@YegorKozlov Thank you so much for looking into all of this so quickly. What are the next steps here on the ACS side? When will this change become part of ACS Commons?

@YegorKozlov
Copy link
Contributor

@juliaetate it'll be included in 6.11

@davidjgonzalez Are there any plans for releasing v6.11 soon? I have a number of redirect PRs to include.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants