Prefilling User Details

Sometimes you may want to prefill user details within the Gleam widget to prevent users from having to enter details twice. This may be if a user is already logged into your website, or if you're redirecting users to a Gleam widget after completing another form first.

Applications that support Prefilling:

The first way you can prefill data is by including some extra Javascript on your page. This should be included after your embed code.

<script>
        window.Gleam = window.Gleam || [];
        Gleam.push(['name', 'John Doe']);
        Gleam.push(['email', 'john@doe.com']);
</script>

The main things you can pass are:

  • Name
  • Email
  • DOB

It will also match up with any additional Custom Fields that you have setup.

The second way you can prefill is to pass parameters to the URL. This will only work if you send users to the Gleam Hosted Landing Page or use the iFrame embed option.

You must also encode the parameters & parameter names.

?name=John%20Doe&email=john%40doe.com

You can see how this would work sending users to our demo competition with Prefilling active:

https://gleam.io/iR0GQ/gleam-demo-competition?name=John%20Doe&email=john%40doe.com

Again this method supports:

  • Name
  • Email
  • DOB
  • Custom Fields (note - Custom Fields need to match their respective names under the 'User Details' tab and are case sensitive. E.g. Gleam.push(['Phone', decodeURIComponent(paramPhone[1])]);)

This additional script will allow you grab parameters from your URL and pass it to Prefill the Gleam embedded widget.

<script>
(function() {
  var paramEmail = location.search.match(/[?&]email=([^?&]+)/);
  var paramName = location.search.match(/[?&]name=([^?&]+)/);
  window.Gleam = window.Gleam || [];
  if (paramEmail) {
    Gleam.push(['email', decodeURIComponent(paramEmail[1])]);
  }
  if (paramName) {
    Gleam.push(['name', decodeURIComponent(paramName[1])]);
  }
})();
</script>

See Next Article

Webhook Integration

Premium users can trigger a request to your own endpoint when entries are created. We currently offer two Webhook types which you can setup.