__( 'Where your contacts come from, what they read before they buy, and what they are looking at. Click anything to see the people behind it.', 'nodebook' ) ) );
echo '
' . esc_html(
/* translators: %s: time ago */
sprintf( __( 'Updated %s ago', 'nodebook' ), human_time_diff( $data['built'], time() ) )
) . ' · ' . esc_html__( 'Refresh', 'nodebook' ) . '';
if ( ! empty( $data['capped'] ) ) {
echo ' · ' . esc_html__( 'Pages and interests cover the last 12 months.', 'nodebook' );
}
if ( ! empty( $pages['sampled'] ) ) {
echo ' · ' . esc_html__( 'Busy site: based on your most recent 30,000 page views.', 'nodebook' );
}
echo '
';
self::insight( $src, $pages['rows'], (array) $data['demand'] );
// Headline tiles: the first four open the contacts behind them.
$link = static function ( $kind ) use ( $days ) {
return Nodebook_Admin::url( 'nodebook', array( 'from' => $kind . ':' . $days ) );
};
$kpis = array(
array( number_format_i18n( $t['leads'] ), __( 'New contacts', 'nodebook' ), $link( 'new' ), 'user-plus' ),
array( number_format_i18n( $t['customers'] ), __( 'Became customers', 'nodebook' ), $link( 'buyers' ), 'check' ),
array( number_format_i18n( $t['returning'] ), __( 'Came back to your site', 'nodebook' ), $link( 'back' ), 'eye' ),
);
if ( $woo ) {
$kpis[] = array( Nodebook_Report::money( $t['revenue'] ), __( 'Revenue from new contacts', 'nodebook' ), add_query_arg( array( 'orderby' => 'total_spent', 'order' => 'desc' ), $link( 'buyers' ) ), 'activity' );
}
$measured = (int) ( $ttc['measured'] ?? 0 );
$kpis[] = array(
null === $ttc['days'] ? '—' : self::days( (float) $ttc['days'] ),
__( 'From first visit to converting', 'nodebook' ),
'',
'clock',
$measured
/* translators: %s: number of contacts */
? sprintf( _n( 'Median of %s contact', 'Median of %s contacts', $measured, 'nodebook' ), number_format_i18n( $measured ) )
: __( 'Appears once tracked visitors convert', 'nodebook' ),
);
echo '
' . esc_html__( 'Nothing yet. This fills up when known contacts read pages on your site and then send a form, order or book. Cart, checkout and thank-you pages are left out.', 'nodebook' ) . '
';
/**
* Extra report sections at the bottom of Journeys.
*
* @param int $days Selected period in days (0 = all time).
*/
do_action( 'nodebook_journeys_sections', $days );
echo '
' . esc_html__( 'Tip: add UTM tags to your ads and newsletter links (utm_source, utm_medium, utm_campaign). Google, Microsoft, Meta, TikTok and LinkedIn ad clicks are recognised automatically.', 'nodebook' ) . '
';
Nodebook_Admin::footer();
}
/** Node's take on the period, in one or two lines. */
private static function insight( array $src, array $pages, array $demand ) {
if ( ! Nodebook_Node::on() ) {
return;
}
$calm = 'calm' === Nodebook_Node::personality();
$lines = array();
$best = null;
foreach ( $src as $r ) {
if ( $r['customers'] && '' !== (string) $r['source'] && ( ! $best || $r['customers'] > $best['customers'] ) ) {
$best = $r;
}
}
if ( $best ) {
$lines[] = sprintf(
/* translators: 1: source, 2: number of customers */
$calm ? __( 'Most customers came from %1$s (%2$s).', 'nodebook' ) : __( 'Your best source: %1$s, good for %2$s customers.', 'nodebook' ),
Nodebook_Attribution::label( $best['source'], $best['medium'] ),
number_format_i18n( $best['customers'] )
);
}
if ( $pages ) {
$lines[] = sprintf(
/* translators: %s: page */
$calm ? __( 'Read most before converting: %s.', 'nodebook' ) : __( 'People who buy often read %s first. Make it shine ✨', 'nodebook' ),
self::page_name( $pages[0]['path'] )
);
}
foreach ( $demand as $r ) {
if ( $r['hot'] ) {
$lines[] = sprintf(
$calm
/* translators: 1: product or item, 2: number of people */
? _n( '%1$s has %2$s hot visitor right now.', '%1$s has %2$s hot visitors right now.', $r['hot'], 'nodebook' )
/* translators: 1: product or item, 2: number of people */
: _n( '%1$s is hot right now: %2$s person looking 🔥', '%1$s is hot right now: %2$s people looking 🔥', $r['hot'], 'nodebook' ),
$r['title'],
number_format_i18n( $r['hot'] )
);
break;
}
}
if ( ! $lines ) {
$lines[] = $calm ? __( 'Not enough data in this period yet. Try a longer period.', 'nodebook' ) : __( 'Not much to go on in this period yet. Try a longer one 👀', 'nodebook' );
}
echo '