APIs & Integrations

natehall15
Mitglied

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

0 Upvotes
7 Antworten
natehall15
Mitglied

Identifying URLs with Query Strings in custom JS events?

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

0 Upvotes
Dadams
HubSpot Employee
HubSpot Employee

Identifying URLs with Query Strings in custom JS events?

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

0 Upvotes
natehall15
Mitglied

Identifying URLs with Query Strings in custom JS events?

Awesome, that will do! Thanks again @dadams!

0 Upvotes
Dadams
HubSpot Employee
HubSpot Employee

Identifying URLs with Query Strings in custom JS events?

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.

0 Upvotes
natehall15
Mitglied

Identifying URLs with Query Strings in custom JS events?

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

0 Upvotes
Dadams
HubSpot Employee
HubSpot Employee

Identifying URLs with Query Strings in custom JS events?

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

0 Upvotes
natehall15
Mitglied

Identifying URLs with Query Strings in custom JS events?

Perfect. Thanks so much for your help!

0 Upvotes