queryStringParameter( )

Studio

queryStringParameter( )

queryStringParameter(param: string): (undefined|string[]);

Returns

An array of decoded string values for a given parameter from the query string passed in a deep link.

The query string is everything after the ? character.

Default value: undefined

An unmodified form of the original query string is avialable by calling queryStringRaw( ) though this method is recommended.

Example

Assuming the deep link https://zpr.link/ZID?myname=Zap%20Bot&myfriend=Mark&myfriend=Connell launched this experience with ZID being the deep link of this experience we can access the query string as follows:

// Get the parameters we passed into the query string
let name = Z.device.queryStringParameter("myname");
let friends = Z.device.queryStringParameter("myfriend");

// Check the value returned exists and isn't empty
if (name && name.length > 0) {
    // Store the first element of the returned array
    let myname = name[0]; // myname holds the value 'Zap Bot'
}

if (friends && friends.length > 0) {
    // Store the entire Array 
    let myfriends = friends; // myfriends holds the value ['Mark', 'Connell']
}
Open in new window