URL parameters for wix site (velo, javascript ?)

I have a page like www.nameofwebsite.com/test-form?code=TEST

I want to use url parameters like we can do in php with $_GET to show the value “TEST” of the variable “code”.

We can’t use php in wix
but I see javascript code to find variables in url parameters
I test javscript code but it doesn’t work.

I test the javascript below but i think that window.location show an other url page

<script type="text/javascript">
  function $_GET(param) {
	var vars = {};
	window.location.href.replace( location.hash, '' ).replace( 
		/[?&]+([^=&]+)=?([^&]*)?/gi, // regexp
		function( m, key, value ) { // callback
			vars[key] = value !== undefined ? value : '';

	if ( param ) {
		return vars[param] ? vars[param] : null;	
	return vars;

var idtech = decodeURI($_GET( 'idtech' ));


Anyone can help me please ???

thank you very much

Hey there,

You cannot use regular javascript expressions with Wix, you will need to use Velo instead.

Here’s how how you can extract query parameters from the URL using Velo:

Thank you very much Pratham,
I think it’s exactly what i was looking for

1 Like

Hello Pratham,
I try the ressource that you sent me
I try to put the url parameter in my frontpage
but it doesn’t work

$w.onReady(function() {
import wixLocationFrontend  from 'wix-location-frontend';

let query = wixLocationFrontend.query; 
const name= wixLocationFrontend.query;

$w("#text-to-test").text= "Hello " + name;


Anyone can help me just to show the query in url parameter on my page ?

You’ve figured most of the stuff out (:

Just two little edits:

const query = wixLocationFrontend.query; 
const name = query.name;

This is because query is an array of key value pairs and you need to extract the name from the array.

And the module needs to be imported before the $w.onReady()

I’ll show you one example:

So the code will be:

import wixLocationFrontend  from 'wix-location-frontend';

$w.onReady(function() {

    let urlQuery = wixLocationFrontend.query; 

    const userName = urlQuery.name; // Output: "Harry"
    const userCode = urlQuery.code; // Output: "TEST"

    $w("#text-to-test").text = "Hello " + userName; // Output: Hello Harry

1 Like

It is perfect !
You are perfect Pratham

I can change the text “#test-to-test” it write “Hello Harry”
It is perfect

Now i must verify if “userName” is not empty
and i must prefill the input text of a form with the name “Harry”

I try to do that,
i’m very happy of your help

1 Like

You’re very welcome!

Feel free to reach out to the community if you have any other doubts or questions and we will try our best to help you.

Happy coding! (: