How to retrieve the URL that was typed when a user lands on the 404 error page?

My goal: send information to Google Analytics (GA) regarding which page a user tried to reach when he/she lands on my 404 error page.

Currently, I am already sending events to GA when someone lands on my 404 page. But it would be helpful to add the complete URL the user tried to reach to the payload. Currently, the wixLocation.url variable always return “error404” on the 404 page, even though on my browser URL bar I have a different URL .

Example of current behavior:

  1. User tries to reach mywebsite.com/page-that-doesnt-exist

  2. Since this page doesn’t exist, the person is redirected to my 404 page

  3. On the 404 page, the browser url bar still shows mywebsite.com/page-that-doesnt-exist , but the wixLocation.url returns “error404”.

If you have a premium account, you can create a 404 page of your own,
and you can try adding some code to retrieve the page url (wixLocation) and save it to the database (I’ve never tried to do it, but I don’t see a reason why wouldn’t it work).

Maybe it’s not clear on my post. This is exactly what I have. But the problem I am facing is the behavior of the wixLocation library. The wixLocation.url always return the same value (“error404”) for any wrong URL my customer may type.

In other words, there is no way for me to know what did my customers typed wrongly because the wixLocation.url always return the same “error404” string instead of the actual URL the customer typed.

I am also looking solution for same. If having any updates please share here
https://www.wix.com/corvid/forum/community-discussion/need-to-read-param-value-from-url-when-page-is-not-found
Thanks