/** * WordPress dependencies */ import { useSelect } from '@safe-wordpress/data'; import { createInterpolateElement } from '@safe-wordpress/element'; import { _x, sprintf } from '@safe-wordpress/i18n'; /** * External dependencies */ import { store as NAB_DATA, usePluginSetting } from '@nab/data'; import { EMPTY_ARRAY } from '@nab/utils'; import type { Goal as RealGoal } from '@nab/types'; /** * Internal dependencies */ import { useExperimentAttribute } from '../hooks'; type GA4GoalSettings = Required< Required< RealGoal >[ 'attributes' ] >[ 'ga4' ]; export function GA4Tracking(): JSX.Element | null { const isGA4TrackingEnabled = usePluginSetting( 'isGA4TrackingEnabled' ); const settings = useGA4Settings(); const { disabled: isGA4GoalTrackingDisabled, eventName: ga4EventName, goalName: ga4GoalName, } = settings; if ( ! isGA4TrackingEnabled ) { return null; } if ( isGA4GoalTrackingDisabled ) { return (
${ ga4EventName || 'conversion' }`,
`${ ga4GoalName }`
)
: sprintf(
/* translators: %1$s: Event name. */
_x(
'This goal is synced with Google Analytics using the event %1$s.',
'text',
'nelio-ab-testing'
),
`${ ga4EventName || 'conversion' }`
),
{
code: ,
}
) }