MadKudu Docs

Home

Fire a Segment Event from a MadKudu Form

Overview

Before getting started, here’s a quick overview of what we are going to be doing:

  • How to create the event properties
  • Example events
  • How to fire the Segment event

For more information about Segment events, check out their documentation.

Step 1: Create a MadKudu Form

Follow the steps here to create a form.

Step 2: Create the event properties

In your MadKudu form, create a variable to define the properties you want to push in the event.

Here is an example where we create an event when a lead is qualified. The properties we want to track here are the customer fit, the url, and the MadKudu campaign id where the event was captured. Put the following code in the Customization of your page section of the form.

var properties = {
    email: email
    customer_fit: madkudu.user().traits().customer_fit.segment,
    url: window.location.href,
    mk_campaign_id: '{campaign id}'
};

In the MadKudu app on the Campaign page, you can find your campaign ID in the URL:

Step 3: Fire the Segment event

Once the properties are defined, you can fire the Segment event with the following code in the Customization of your page section, replacing {event name} with a name of your choice.

  analytics.track('{event name}', properties);

Step 4: When to fire the event

Depending on when you want the event to fire, you can execute this code into different areas of the MadKudu form.

1 Create a function containing the code from Steps 2 and 3

form.fire_segment_event = function () {
  var email = $("#inputEmail").val();

  // Define properties 
  var event_properties = {
      email: email
      customer_fit: madkudu.user().traits().customer_fit.segment,
      url: window.location.href,
      mk_campaign_id: '{campaign id}'
  };

  // Fire track event
  analytics.track('{event name}', properties);
}

2 Decide when to fire the event

Then you can fire the Segment at the different times:

  • When the visitor is qualified in the What to do when a visitor is found to be qualified section
  • When the visitor is not qualified in the What to do when a visitor is found to be NOT qualified section
  • Or in both sections to fire the event for all visitors

Other event examples

A few other times you might want to fire a Segment event from your MadKudu form:

  • When a visitor submits a form on your website
  • When a visitor signs up for a trial
  • When a MadKudu form is triggered