Skip to main content
Form Tracking

How-to track location fields auto-filled by Google Places

By November 26, 2023No Comments

Insiteful can help you track form entries and more from virtually any web form in just a few clicks. Many businesses utilize the Google Places API’s Autocomplete function to allow visitors to search and auto-populate multiple location fields from Google Maps. These fields will typically appear something like the below:

Track Google Places autocomplete fields

However, since Insiteful tracking works based on keystrokes, these programmatically-filled fields may not be captured by the default Insiteful tracking script alone. To workaround this, we have provided an additional, customizable script for tracking location fields populated by the Google Places API:

How to track location fields auto-filled by the Google Places API

In order to properly track location inputs that are auto-filled with the Google Places API, you can simply copy and paste the extra line below after the usual install code:

IMPORTANT: Make sure to replace the list of HTML element IDs in the second line (within the “getGoogleMapFormFields” function) with the unique HTML IDs or selectors (ie. “#field_id” or “[name=’field_name’]”) corresponding to the other form fields that are auto-filled by the Google Places API.

<script async defer type='text/javascript' src='//a.insiteful.co/dist/track-google-places.min.js?' id='insiteful-google-places-js'></script>
<script async defer>getGoogleMapFormFields("#street_field, #city_field, #zip_field"); //REPLACE THESE IDS WITH YOUR FORM FIELDS</script>

NOTE: Make sure that the field which allows users to search Google Maps via the Places API has the HTML class “pac-input” for this to function correctly.

How to track partial entries & abandonment in your existing forms

Ready to start capturing & tracking leads from your forms?  With Insiteful, it just takes a couple clicks:
  1. Add your website: Just login to Insiteful & visit the Domains page and add your website where indicated in the screenshot below.
    Insiteful App – Domains Page - Add Website
  2. Install code: Adding Insiteful to your website is as simple as copy and paste: simply add the two codes from the Install page — that’s all there is to it! If some of your inputs are dynamically rendered (ie. hidden / conditional fields) after the page load, copy the the additional tracking code above.
    Insiteful.co: Install Code for Partial Entry Tracking & Form Abandonment Recovery

Was this post helpful?

Get your case studyAvailable for download immediately (no need to check your inbox)!