\Groundhogg\Funnel

📅 Published on

📝 Last updated

Documentation

»

Classes

»

\Groundhogg\Funnel

extends Base_Object_With_Meta

Represents an automation funnel. A funnel is a sequence of steps (actions, benchmarks, timers, and logic) that contacts move through. Use this class to inspect funnel configuration, manage its active state, and access its steps.

Methods

MethodReturnsDescription
get_id()intReturns the funnel ID.
get_title()stringReturns the funnel’s display title.
get_status()stringReturns the funnel status: 'active''inactive', or 'archived'.
is_active()boolReturns true if the funnel is currently active.
get_steps( $query = [] )Step[]Returns an array of Step objects in this funnel, optionally filtered by a query array.
get_step_ids( $query = [] )int[]Returns an array of step IDs.
get_num_steps()intReturns the total number of steps in the funnel.
get_first_step_id()intReturns the ID of the first step.
get_entry_steps()Step[]Returns an array of benchmark (entry) steps.
get_entry_step_ids()int[]Returns an array of benchmark (entry) step IDs.
get_emails()Email[]Returns all Email objects used in email steps within this funnel.
get_email_steps()Step[]Returns all email action steps in this funnel.
get_conversion_steps()Step[]Returns all steps flagged as conversion steps.
is_active()boolReturns true if the funnel is active.
pause_events()boolPauses all waiting events for contacts in this funnel.
unpause_events()boolResumes all paused events for contacts in this funnel.
cancel_events()boolCancels all waiting events for contacts in this funnel.
has_errors()boolReturns true if the funnel has configuration errors.
export()arrayReturns the funnel as an exportable data array.
export_url()stringReturns a URL to download the funnel as a JSON export file.
import( $data )boolImports a funnel from an exported data array.

Usage

Here’s a pseudo code example for a hypothetical funnel reporting integration.

<?php

add_action( 'groundhogg/admin/reports/pages/funnels/after_reports', 'my_plugin_append_funnel_report' );

/**
 * Append custom data to a funnel's report page.
 *
 * @return void
 */
function my_plugin_append_funnel_report() {

    $funnel_id = absint( $_GET['funnel'] ?? 0 );
    $funnel    = new \Groundhogg\Funnel( $funnel_id );

    if ( ! $funnel->exists() ) {
        return;
    }

    echo '' . esc_html( $funnel->get_title() ) . ' — My Plugin Stats';
    echo 'Steps: ' . $funnel->get_num_steps() . '';
    echo 'Status: ' . esc_html( $funnel->get_status() ) . '';

    foreach ( $funnel->get_emails() as $email ) {
        echo 'Email: ' . esc_html( $email->get_title() ) . '';
    }
}

Was this helpful?

Let us know if this document answered your question. That’s the only way we can improve.