Solved

Query accidentally recognized as hash?

  • 14 February 2023
  • 2 replies
  • 53 views

Userlevel 1
Badge +1

Example url on our website: 

https://app.mydrugcosts.com/#/rx-outreach?PharmacyId=844&PharmacyType=6&termId=189805&qty=1&name=Neulasta&form=Solution%20Prefilled%20Syringe&strength=6%20MG%2F0.6ML&days=30&doseId=174&RealDrugId=neulasta

 

I need this event to be tracked but when I add a Query filter for PharmacyId=844 heap reports 0 occurrences of this event. When I change it to a hash filter it seems to work. Any idea why?

 

 

icon

Best answer by jonathan 15 February 2023, 01:00

View original

2 replies

Userlevel 5
Badge +3

Hey @Riomanty — this is a great question. The HTML spec says that hashes have to be the last part of the URL. Anything after the hash is considered part of the hash. This was all fine and good back in the day before certain single page app frameworks decided to break how the web was supposed to work and make anchor tags the new pageview. So it goes.

Heap follows the spec and so when we see URLs such as yours, we store that in the Hash property and not the Query property. 

 

The right way to build this url is to add the query before the hash when the url is rewritten by the behavior that adds the query. That’s admittedly not very ergonomic, but it would solve the problem. Other than filtering on Hash, as you have already done, another option is to use Defined Properties to extract out the relevant values from the Hash. These aren’t currently able to be used in event definitions, but can be used in reporting and might be more scalable depending on your reporting needs. e.g.
 

 

Userlevel 1
Badge +1

Many thanks! This answers my question completely

Reply