Coding Workshop: External Action for Lead Acquisition

| Time to read: 11 minutes

Coding Workshop: External Action for Lead Acquisition

In this coding workshop, we'll dive into a common endeavor: setting up a lead acquisition pipeline from a website or any other source. This article showcases how simple it can be to integrate your Every8.Cloud account with any external system. Constructing a lead acquisition channel is a specific example just to make this article more engaging 🎯😊


So, what are External Actions?

First off, it's important to understand what Actions are. Actions are metadata objects with their own unique address. When you reach out to this address, a specific action is triggered, and a result is returned. This result could be a JSON object, a file, or even a redirection to another form or page. Actions, for example, are frequently used to automate often used functions, worth identifying as separate elements in an application. A perfect illustration is the automatic generation of a PDF file before sending it to a client.

External Actions play the same role as Internal ones, with the only difference being that they are accessible to unregistered users. Consider them as Endpoints with an extended feature set.


How can External Actions be used?

Their use cases are pretty broad, primarily serving as a tool for integrating with external systems. In this article, we'll look at a specific application, namely capturing leads from a website.

The simplest method to capture leads from a site is, of course, to create an embedded form and just publish a chunk of code on the webpage. All you need for this is access to the webpage's source code.

In some instances, this approach may not work. While an embedded page allows for style customization, aligning the styles of the site and the embedded page can sometimes be a challenging task. An embedded page also employs the iframe mechanism, which some search engines aren't particularly fond of.

If these factors are crucial in your case, you can create an External Action and have it communicate with your standard HTML form on the site.


Creating an External Action

An External Action can either be a part of an app or additional functionality on the Implementation Layer.

Let’s create an action.

Make it external on the Security tab.

Switch to Script mode and shift your mindset into developer mode 😁.

This code performs the following actions:

  1. First of all, we check that the incoming request is of type POST (E8App.$request.isPost())

  2. In case of an incorrect type, we return the appropriate status (E8App.$response.setStatusCode(405))

  3. Next, we obtain the object sent to us (E8App.$request.post())

  4. You'd think here you could take values from the object and form a lead, but no. First, we need to validate the received data. Maybe it does not meet the minimum requirements for lead generation.

  5. For this, we use a validator plugin (E8App.$validator.create(object)). Then we configure the validator by adding rules to it (for example, validator.addRule('phoneNumber', E8App.$validator.V_REQUIRED))

  6. We perform validation of the received data (validator.validate()) and in case of detection of errors, we return an error.

  7. After thet we create an object in the database. 


Connect the Action to the Site

We create a page on which we place all necessary fields. By pressing the button, we call the action with the transfer of form data.

This is an example of a form. Your form may contain other fields.

Please promise us to make it even nicer than that!👍

And the result:


Conclusion

While this might seem a bit daunting at first, this article dives into a more intricate method of lead collection from a website.

The good news is that once you've mastered this, you can use it across various platforms, be it forms on Facebook, LinkedIn and beyond.

Still not sure you can navigate this on your own?

No worries - we're here and ready to help!

All articles Share this post:

Every8.Cloud Product Tour Request

Let’s get started!

{{ vars.errorMessage }}
{{ vars.successMessage }}