Is there a way to make the webbrowser submit additional HTTP header if the user clicks on a link?
Background: In our environment every http-request has a unique ID on the server side. See https://serverfault.com/questions/797609/apache-x-request-id-like-in-heroku
If your web application receives a http-request, I would like to know which page was the page before. The http referrer is not enough, since the user could use several tabs in his browser.
I would like to avoid to put the ugly request-id into every GET request which gets send from the browser to the server. Up to now our URLs are nice.
My prefered solution would be some JavaScript magic which adds the request-id of the current page into the next http request.
Steps in detail:
- browser access URL http://example.com/search
- web server receives http request with request ID 123
- web server sends content of the URL to the browser (a search page). The page includes the request ID 123 somewhere
- the user searches for "foobar".
- the web browser submits a http request to the server and includes the previous request id somehow.
- web server receives second http request (ID 456) and can access the value of the first request (ID 123) somehow.
- Web server can store the relation "123 --> 456" in a database for later analysis.
My goal is to track the relations "123 --> 456". Above solution is just a strategy to get to the goal. Other strategies are welcome.
We use the web framework django. But AFAIK this does matter in this context.
the user could use several tabs in his browser
I elaborate what that means for a matching solution. The sequence of requests which come from one user does not solve the issue.
One use with several tabs:
- user looks at page A in tab1
- user looks at page B in tab2
- user follows a link on page A to page C
- user follows a link on page C to page D
- user follows a link on page B (tab2) to page E.
I want to know see two sequences:
A -> C -> D
And
B -> E