Identifying URLs with Query Strings in custom JS events?

New Member

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: https://knowledge.hubspot.com/events-user-guide-v2/using-custom-events

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: https://siftscience.com/?utm_source=google&utm_medium=cpc&utm_term=sift-science&utm_content=sift-sci...

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!
Nate

Reply
0 Upvotes
7 Replies 7
HubSpot Moderator

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.

Reply
0 Upvotes
New Member

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

Reply
0 Upvotes
HubSpot Moderator

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

Reply
0 Upvotes
New Member

Perfect. Thanks so much for your help!

Reply
0 Upvotes
New Member

@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 “https://siftscience.com/?utm_source=google&utm_medium=cpc&utm_term=sift-science&utm_content=sift-sci...”?

Reply
0 Upvotes
HubSpot Moderator

@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:

http://www.example.com/page/?key=value*

would match any URL starting with http://www.example.com/page/?key=value* along with any additional query parameters that were at the end.

Reply
0 Upvotes
New Member

Awesome, that will do! Thanks again @dadams!

Reply
0 Upvotes