Update _source
Parameter Used by Proxy Event Tracking Function Citing Site Kit as Source of ICE Events & Rename trackEvent
#8815
Labels
javascript
Pull requests that update Javascript code
P0
High priority
PHP
Team S
Issues for Squad 1
Type: Enhancement
Improvement of an existing feature
Feature Description
#8641 saw the introduction of a helper/proxy style function to facilitate the tracking of events against gtag's. This function is merely an abstraction against the
gtag('event')
API call.However, it was incorrectly instructed that the custom event parameter name citing Site Kit as the source of the event be
_source
. This is an illegal parameter name as said parameter names may only be alphanumeric and contain underscores, but may not begin with an underscore.This custom
_source
event parameter name should be updated to beevent_source
.No updates to individual event provider scripts are needed, as they all leverage this helper function.
Further to the event parameter name change, the current
trackEvent
function name should be updated to be something a little further removed from the internaltrackEvent
function of the same name. A suitable name would begtagEvent
. This will need to be updated across all existing event provider JS scripts, as they currently call theglobal._googlesitekit?.trackEvent?.()
function as part of individual event provider logic.Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
trackEvent
function inincludes/Core/Conversion_Tracking/Conversion_Tracking.php
(created aswp_add_inline_script()
) should be updated to be namedgtagEvent
.window._googlesitekit.trackEvent()
should have their JS code updated to instead referencewindow._googlesitekit.gtagEvent()
_source
parameter passed togtag()
within the (now updated)gtagEvent()
function atincludes/Core/Conversion_Tracking/Conversion_Tracking.php
(created aswp_add_inline_script()
) should be updated to be namedevent_source
Implementation Brief
includes/Core/Conversion_Tracking/Conversion_Tracking.php
wp_add_inline_script()
call definingwindow._googlesitekit.trackEvent
and renametrackEvent
togtagEvent
_source
gtag event parameter and rename it toevent_source
assets/js/event-providers
global._googlesitekit?.gtagEvent
where there is current usage ofglobal._googlesitekit?.trackEvent
Test Coverage
QA Brief
conversionInfra
feature flag in Site Kit Tester plugingtag('event')
API call, the (previously named)_source
event parameter should now be listed asevent_source
as per the screenshot below:Changelog entry
event_source
instead of__source
.The text was updated successfully, but these errors were encountered: