Identifying URLs with Query Strings in custom JS events?


#1

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-science-official&utm_campaign=sift-science-exact&gclid=CJaz5LXG5tMCFYmffgodLi4IuQ

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


#2

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.


#3

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


#4

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


#5

Perfect. Thanks so much for your help!


#6

@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-science-official&utm_campaign=sift-science-exact”?


#7

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


#8

Awesome, that will do! Thanks again @dadams!