(Optional) Additional Events

fireCustomGoal

Sends an event to Northbeam indicating that a custom goal has happened. This helps you track and analyze milestones unique to your customers' journeys.

Examples:

  • custom quote form fills
  • SMS signups
  • add-to-cart events

Note: if you'd like to track a new custom goal, please get in touch with the Northbeam team and share the names of your custom goals so they can be recognized in the Northbeam system.

window.Northbeam.fireCustomGoal("add_to_cart", {})
ArgumentTypeDescription
1requiredStringThe name of the custom goal. Please email [email protected] with this name.
2optionalObjectThe total amount collected for the purchase.

fireEmailCaptureEvent

Sends an event to Northbeam indicating that a user has signed up for something with their email address.

Note: if you fire an email capture event, there is no need to call identify - fireEmailCaptureEvent implicitly does an identify() call in the backend.

window.Northbeam.fireEmailCaptureEvent("[email protected]", "klaviyo_footer")
ArgumentTypeDescription
1requiredStringThe email address
2StringThe location identifier describing where the email was captured.

identify

Identifies the current user with a particular real-world identifier. Better enables Northbeam to understand cross-device activity.

Currently only works with email addresses.

window.Northbeam.identify("email", "[email protected]")
ArgumentTypeDescription
1requiredStringThe string "email"
2requiredStringThe email address

trackPageView

If your website uses JavaScript based routing, use this method to track transitions with pages.

For example, if you're using React Router, call this method after a page transition to track the change to a new location. (https://reactrouter.com/en/main/hooks/use-location)

// Default Example
window.Northbeam.trackPageView()

// React Router Example
import * as React from 'react';
import { useLocation } from 'react-router-dom';

function App() {
  let location = useLocation();

  React.useEffect(() => {
    window.Northbeam.trackPageView();
  }, [location]);

  return (
    // ...
  );
}

Add a onload callback function for the Northbeam Pixel (onNorthbeamLoad)

If you want to perform a Northbeam action on your site before the pixel has been loaded (e.g. if you want to do something as soon as your page loads instead of waiting on user action to kick it off), you can use this method to make sure we do what you need done as soon as our pixel is loaded.

<script type="text/javascript">
    const func = () => {
      // get args
      window.Northbeam.firePurchaseEvent(args)
    }

    if(window.Northbeam){
        // if Northbeam is already loaded, just call the 
        // firePurchaseEvent function
        func()
    }else{
        // If Northbeam is not loaded, save your function
        // in window.onNorthbeamLoad, so the pixel will call
        // it as soon as window.Northbeam is defined.
        window.onNorthbeamLoad = func
    }
</script>