WealthFit.Campaigns.Shared.CreateOptin (Peacemaker v3.3.5-rc.7) View Source

The generic interface for Creating Optins for any campaign.

This module was specifically designed to help normalize the process for letting customers set their password after creating their account (as opposed to the legacy version where they were emailed a link with a login token or plaintext password)

Our current process for setting up a WealthFit Optin looks something akin to:

  1. Ensure that a WealthFit Optin Database record is created
  2. Ensure that a Sticky.io Prospect record is created
  3. Update the the associated User Profile record to include the most recent optin campaign.
  4. Ensure any analytic events get reported. Checkout WealthFit.Analytics.Optin for more information.

This module is setup to be called after the user has given us their name and email, with the intent of eventually creating a WealthFit account in the same campaign. A current example at the time of this writing is how the /free-account/ funnel behaves.

From a technical perspective, the flow is intended to be something like:

  1. Create an Optin using this module (WealthFit.Campaigns.Shared.CreateOptin). This returns a shortlink token that can be authenticated at a later date (up to 90 days) by sending that token to the /activate_account endpoint.

  2. Sending a POST to /activate_account with the given token is a crucial step for ensuring that the client is authorized to set their initial password. If you skip this step and instead directly call /set_initial_password after creating the optin, the system will throw an error because there is no http-only cookie attached, thus it is unable to find the associated account. Activating the account also has this assumed behaviour that the caller of this module will set the JWT in the cookie before returning the Plug.Conn request.

Another important thing to note here is that there is also a requirement for us to possible give the account access to one of our Classes for free. This would be the layer to do so. By passing a class_prismic_id, we can associate a single free class to the account so that it is visible in their dashboard and ready to watch.

  1. Set the initial password. This is a pretty straightforward module and no real implicit-assumptions like what the Activate Account contains. For more information, checkout WealthFit.Authentication.SetInitialPassword.

NOTE on Maropost Support:

A token is generated and stored in the Links table in the WealthFit Database as well as on the Maropost Contact as a custom field. We store the token on the Maropost Contact to allow the marketing team the ability to deliver follow-up emails if the account has did not log into the app after x amount of time.

The current maropost implementation relies on the WF3 Leads - xx - Created Password tag to be set on the contact to state that the user has logged in, because after the user sets their initial password we immediately forward them to the dashboard. For now, these tags are to be sent from the Frontend application.

Link to this section Summary

Link to this section Types

Specs

payload() :: %{
  conn: Plug.Conn.t(),
  payload: %{
    first_name: String.t(),
    last_name: String.t(),
    email: String.t(),
    ip_address: String.t(),
    campaign_id: String.t(),
    phone: String.t(),
    maropost_tags: [String.t()],
    optin_asset_id: String.t(),
    optin_asset_name: String.t()
  }
}

Specs

token() :: String.t()

Link to this section Functions

Specs

run(payload()) :: {:ok, token()}