Identifying URLs with Query Strings in custom JS events?


When creating a custom Javascript event in Hubspot you can add a URL so that the event only triggers on a certain page. That’s described in this article:

If there is a querystring in the URL, will the event be able to distinguish between URLs with that query string and without it? Or can it not identify unique URLs created with that string?

To give some context, we are trying to create an event for when someone comes to our homepage from a paid search ad. This would only fire if the lead visits this URL with a unique query string:

Would love to do this with the normal enrollment criteria, but Hubspot doesn’t support identifying different URLs by query string…

Thanks for your help!


Hi @natehall15

If you’re creating a Visited URL event, the event will support a query string, and the event will only be triggered if the URL matches exactly, so if you include a query string in the Page URL when creating the event, the event would only fire if the visited URL matches the query string exactly.


Thanks @dadams! In that case I wouldn’t need to use Custom Event then, is that correct?


Correct, if you’re just looking at the URL being viewed you could use a Visited URL event.


Perfect. Thanks so much for your help!


@dadams Is it possible to use Regex or other expressions to identify a partial piece of the query string in the Visited URL Event? Such as Starts With “”?


@natehall15 we don’t support regex, but you can use * as a wildcard character. Wildcard characters can be used anywhere in the URL, including the end of the string, so:*

would match any URL starting with* along with any additional query parameters that were at the end.


Awesome, that will do! Thanks again @dadams!