Documentation » Classes

\Groundhogg\Step

Published · Last updated

extends Base_Object_With_Meta implements Event_Process

Represents a single step inside a funnel — an action, benchmark (trigger), timer, or logic step. Every step belongs to a funnel and has an ordered position within it. Use this class to inspect step configuration, navigate the funnel structure, or get the contacts currently waiting at this step.

Methods #

MethodReturnsDescription
get_id()intReturns the step ID.
get_title()stringReturns the step’s display title.
get_type()stringReturns the step type slug (e.g. 'send_email', 'apply_tag', 'form_filled').
get_type_name()stringReturns the human-readable label for the step type.
get_group()stringReturns the step group: 'action', 'benchmark', 'logic', or 'timer'.
get_order()intReturns the step’s position within the funnel.
get_funnel_id()intReturns the ID of the funnel this step belongs to.
get_funnel()FunnelReturns the Funnel object this step belongs to.
is_action()boolReturns true if this is an action step.
is_benchmark()boolReturns true if this is a benchmark (trigger) step.
is_logic()boolReturns true if this is a logic step.
is_conversion()boolReturns true if this step is flagged as a conversion step.
is_entry()boolReturns true if this is an entry (first benchmark) step.
is_last()boolReturns true if this is the last step in the funnel.
type_is( string $type )boolReturns true if the step’s type slug matches $type.
get_waiting_contacts()Contact[]Returns an array of contacts currently waiting at this step.
get_waiting_events()Event[]Returns an array of events currently waiting at this step.
get_next_action( Contact $contact )Step|falseReturns the next action step that will run for the given contact.
get_prev_action()Step|falseReturns the preceding action step.
get_preceding_steps()Step[]Returns all steps that precede this one in the funnel flow.
get_proceeding_actions()Step[]Returns all action steps that follow this one.
get_sub_steps()Step[]Returns child steps if this is a logic branch step.

Usage #

Here’s a pseudo code example for a hypothetical step analytics integration.

<?php

add_action( 'groundhogg/event/complete', 'my_plugin_log_step_completion' );

/**
 * Log when a contact completes a step, with step type context.
 *
 * @param \Groundhogg\Event $event
 *
 * @return void
 */
function my_plugin_log_step_completion( $event ) {

    $step    = $event->get_step();
    $contact = $event->get_contact();

    if ( ! $step || ! $contact ) {
        return;
    }

    my_plugin_record_completion( [
        'contact_id' => $contact->get_id(),
        'funnel_id'  => $step->get_funnel_id(),
        'step_id'    => $step->get_id(),
        'step_type'  => $step->get_type(),
        'step_group' => $step->get_group(),
        'is_conversion' => $step->is_conversion(),
    ] );
}