New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent duplicate Ads conversion tracking ID output #8455
Comments
I wanted to find out how this problem came into existence in the first place. This seems to be related to #8248, which took a different approach to migrating the The design doc planned for a version-specific database migration (like we recently did with the Singular Analytics Module) where if an However, during the definition of #8248, it was decided that the migration would happen only when the user goes to Site Kit Settings and opens the Analytics settings edit/view screens. This would allow Analytics to still output the tag until the migration was done, after which Ads would take over. However, I don't think a scenario was taken into consideration where a user could connect the Ads module without the migration being performed, thus causing the duplicate tags as described in the issue description. If a DB migration was done here instead, it would be guaranteed that the conversion ID, if exists, would only exist in the Ads module. As a result, outputting the Ads conversion ID tag could be solely a concern of the Ads module, and the entire mechanism to store and output an Ads conversion ID could be removed from the Analytics module. This would ensure that there would be no duplicate tags. @10upsimon will be able to share details regarding this decision as soon as he's back from his time off, but I'm sure he had valid concerns with the original database migration plans, thus, choosing to do a conditional runtime migration instead. Based on the comment here, I think the decision was mostly influenced by the necessity to make the user aware of the location change of the Ads Conversion ID field. I've drafted two potential paths, one of which we can take to remedy the reported problem in this issue:
@10upsimon & @aaemnnosttv: I'll leave the decision-making step to you. Thank you! CC: @zutigrm |
Per discussion in Slack, I've changed this to a P1 and removed it from Sprint 124 as we don't consider it to be a launch blocker for the Ads Module launch. |
@nfmohit @10upsimon I think a one time DB migration makes sense for the handling related to moving the conversion ID value between modules. The concern of a temporary notice within GA can be handled separately similar what we do for new badges, but the two don't need to happen at the same time. It's possible they could use some shared state but if we had to choose, I'd rather have the temporary notice triggered by the migration in the background rather than trigger the migration as a side-effect of viewing the module settings (even if that means the notice isn't seen right away). |
@10upsimon Let me know if you have any questions about the direction here 👍 |
@10upsimon As noted in Slack, I'm going to add a |
ACs are good, moving to IB 👍🏻 |
I've created an IB based on all of the comments above taking the approach of creating a db migration which migrates the Ads Conversion ID if present in the Analytics module settings and activating the Ads module as well as setting the existing As mentioned above we could/should create a follow up ticket to refactor |
@benbowler Can you create that follow-up issue? Fine to leave an outline and move it to the triage/AC column 👍🏻 IB here looks good, I think it makes sense 🙂 IB ✅ |
Bug Description
While #8313 implements an independent ability for the Ads module to output the Ads conversion tracking ID, it doesn't prevent the Analytics module from still outputting this tag if still set.
We have #8248 that migrates the Ads conversion tracking ID from the Analytics to the Ads module thus effectively removing it from the Analytics module, however, keep in mind that this migration is conditional. This migration will only happen if the user goes to Site Kit Settings and opens the Analytics settings edit/view screens. See this AC from #8248:
Let's take the following scenario into consideration:
The above steps will make Site Kit output two tags for the Ads conversion tracking ID, one from the Analytics module, and the other from the Ads module. Here's a screenshot of an experiment I did to replicate the above scenario:
I think the above scenario can potentially cause duplicate/erroneous tracking, and should be addressed.
Steps to reproduce
adsModule
feature flag yet.adsModule
feature flag.Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Implementation Brief
Version Specific Migration
Migration_n_e_x_t.php
(replacing n_e_x_t with the version this feature is expected to be released) which always migrates the adsConversionID from the Analytics Module to the Ads Module, if found, and activates the Ads Module. Use theincludes/Core/Util/Migration_1_123_0.php
file as the base structure of the migration.DB_VERSION
property in the Migration class to the version in which this feature will be deployed.$context
,$options
,$ads_settings
and$analytics_settings
class properties and in the constructor, set them in the same way as in the 1.123.0 migration, with the addition of theGoogle\Site_Kit\Modules\Ads\Settings
class which should be included and instantiated to$ads_settings
property.migrate
method should check the current database version using$this->options->get( self::DB_VERSION_OPTION );
and if this value is falsy or belowself::DB_VERSION
using theversion_compare
function then it should run two migration methods:$this->migrate_analytics_conversion_id_setting();
$this->activate_ads_module();
migrate_analytics_conversion_id_setting
method:null
if! $this->analytics_settings->has()
.analytics-4
module using$this->options->get( Analytics_4::MODULE_SLUG );
adsConversionID
setting exists and is not empty on theanalytics-4
module:adsConversionID
on the Ads module, in this case, remove the value from the Analytics module settings using$this->analytics_settings->delete('adsConversionID')
.adsConversionID
in the ads module:adConversionID
on the Ads module settings using$this->ads_settings->set('adsConversionID', $analytics_settings['adsConversionID'])
adsConversionIDMigratedAtMs
on the Ads module settings to the current timestamp, in order to show the banner in the frontend later, using$this->ads_settings->set('adsConversionID', time() * 1000)
$this->analytics_settings->delete('adsConversionID')
.activate_ads_module
method:ads
slug in the$active_modules = $this->options->get( 'googlesitekit-active-modules' );
array.adsConversionID
has been added to the Ads module options in themigration_analytics_conversion_id_setting
method, by getting the ads module options using$this->ads_settings->get('adsConversionID')
and checking that it is truthy.$active_modules
array using$active_modules[] = Ads::MODULE_SLUG
then updating the active modules using$this->options->set( Modules::OPTION_ACTIVE_MODULES, $option );
Remove Frontend Migration Logic
assets/js/modules/analytics-4/hooks/useMigrateAdsConversionID.js
and both uses of theuseMigrateAdsConversionID
hook from AnalyticsSettingsView
andSettingsEdit
.Update the Analytics Notification Logic
assets/js/modules/analytics-4/components/settings/AdsConversionIDSettingsNotice.js
behaves as expected with theadsConversionIDMigratedAtMs
setting now being added by the migration.Test Coverage
assets/js/modules/analytics-4/hooks/useMigrateAdsConversionID.test.js
.tests/phpunit/integration/Core/Util/Migration_n_e_x_tTest.php
that tests these key cases:adsConversionID
adsConversionID
where:adsConversionID
QA Brief
Changelog entry
The text was updated successfully, but these errors were encountered: