Append Listing Search Form HTML Code

Hi,

I am using hotjar to record user activity on this site: https://nearme.herafertility.co/

Hotjar link: https://help.hotjar.com/hc/en-us/articles/115015563287-How-to-Show-Elements-and-Keystrokes-in-Data-Collection

On their website it says,
However Hotjar suppresses all keystroke data by default, replacing text with asterisks("***"). Please see screenshot of a recording taken. This is of the Hivepress Listing Search Form (w/ Geolocation plugin) where text has been replaced by asterisks

Further on their website it says,
To allow these elements and keystrokes, you will need to alter your site’s HTML code and add the attribute data-hj-allow to them.

I have tried ‘Edit as HTML’ in Pages->Edit, however that does not display the HTML to which I could append ‘data-hj-allow’

Please instruct how I can accomplish this, as per HotJar instructions, I believe you would have to append this code to both:

(Sorry, the code below I am trying to indicate, is not displaying once posted)

However I haven’t found success in my attempts to append this code

Hi,

Please provide more details on where exactly you want to add it (for example, on the form tag or each field).

Hi, please see the attached 2 screenshots where I have indicated locations of where I wish to add the code


Please try this PHP snippet. But please note that there is no simple snippet to add this attribute to the location field. It requires advanced customization. It is only possible to add the attribute to the location field wrapper block

add_filter(
	'hivepress/v1/forms/listing_search',
	function($form){
		if(isset($form['fields']['s'])){
			$form['fields']['s']['attributes']['data-hj-allow'] = 'custom value';
		}
		
		if(isset($form['fields']['location'])){
			$form['fields']['location']['attributes']['data-hj-allow'] = 'custom value';
		}
		
		return $form;
	},
	1000
);

Hi,

Hotjar is working perfectly for the Keywords field.

Thanks for the info regarding inserting the code for the Location field.

Again, thanks a lot for your snippet, your help was much appreciated.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.