Closed NeoGenet1c closed 6 years ago
This is probably a state based redirection? (note: you can do url based redirections using router.urlService.rules.*
). When UI-Router does a state redirection, it applies the parameter values to state's URL, then constructs the final destination URL. If that url doesn't include a parameter for utm_source
then it's expected that it's not included in the final url.
Suggest you add utm_source
as a query parameter to the state being redirected to and the state being redirected from. To be safe, you could add it as a parameter to some common parent state.
Here's a blitz that demonstrates: https://stackblitz.com/edit/ui-router-angularjs-ex4rmi?file=index.html
Closing as not a bug. Hope the sample helps!
Thanks for the answer @christopherthielen
I still feel this is a bug.
As I already explained, if the state is executed without a redirect andutm_source
is present in the query, the view renders correctly and the utm_source
remains in the URL.
However, if there is a state-based redirect, the utm_source
gets stripped from the URL.
From a user's standpoint, whether or not there is some background redirect should not matter - In one case, the URL query (that's not part of the state's parameters) disappears, in the other, it remains. The behaviour is inconsistent. Why isn't it stripped in both instances?
This issue tracker is for Bug Reports and Feature Requests only.
This is a (check one box):
My version of UI-Router is: v1.0.11
Bug Report
Current Behavior:
When I add a tracking query to the URL (e.g. marketing or Google Analytics queries such as ?gclid or ?utm), ui-router strips it down if the source URL is a redirect.
Example:
www.site.com/page/?tab=main&utm_source=Facebook
gets correctly redirected to: www.site.com/page/redirected?tab=main
... but strips down the 'utm_source' query. This is problematic because Angulartics (Angular.js library for GA) is loaded after the transition is successful, which means it cannot properly track 'utm_source'.
I believe this is a bug/ inconsistent behaviour, because if I invoke a page without a redirect, e.g. www.site.com/page/redirected?tab=main&utm_source=Facebook ... the
utm_source
tag is kept in the URL. The first successful transition should not alter input URL, even if the queries are not matching defined parameters.Expected Behavior:
After accessing a page with a redirect for the first time, e.g.: www.site.com/page/?tab=main&utm_source=Facebook
queries not defined in parameters should be kept in the URL after the transition succeeds: www.site.com/page/redirected?tab=main&utm_source=Facebook