Skip to content
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

Add tracking for campaign count #2137

Merged
merged 5 commits into from
Oct 25, 2023
Merged

Conversation

mikkamp
Copy link
Contributor

@mikkamp mikkamp commented Oct 13, 2023

Changes proposed in this Pull Request:

This PR adds tracking for campaign count and the ads customer ID.

Since the campaign count is retrieved from the Ads API the result is cached for 12 hours to reduce any delays. Since we also fetch a list of campaigns when viewing the dashboard, we use this opportunity to cache the count so when the tracker snapshot is sent it can use a cached value.

The cached values are cleared upon a disconnect, when a campaign is created, or if the transient expires.

Closes #2130

Detailed test instructions:

  1. Test on a site with MC and Ads accounts onboarded
  2. Use a code snippet to output a tracking snapshot to a page:
add_action(
	'admin_init',
	function() {
		if ( ! empty( $_GET['wctracker'] ) ) {
			$tracks = apply_filters( 'woocommerce_tracker_data', [] );
			echo '<pre>' . json_encode( $tracks, JSON_PRETTY_PRINT ) . '</pre>';
			exit;
		}
	}
);
  1. Visit the page: https://domain.test/wp-admin/?wctracker=1 (swap for your admin domain)
  2. Confirm the snapshot data has the correct values for ads_customer_id and ads_campaign_count
  3. Disconnect the ads account and recheck the snapshot data
  4. Confirm the values are both 0
  5. Confirm that the transient _transient_gla_ads_campaign_count is cleared up (after the disconnect)
  6. Reconnect and view the list of campaigns on the dashboard page
  7. Check the DB (or transient manager) to confirm that the transient _transient_gla_ads_campaign_count has been populated

Changelog entry

  • Tweak - Add tracking for campaign count.

@mikkamp mikkamp self-assigned this Oct 13, 2023
@github-actions github-actions bot added the changelog: tweak Small change, that isn't actually very important. label Oct 13, 2023
@mikkamp mikkamp requested a review from a team October 13, 2023 15:12
Copy link
Contributor

@martynmjones martynmjones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @mikkamp, thanks for your work to improve tracking.

Tested this branch and confirmed that the number of campaigns is cached and accurately reported when tracking is enabled so LGTM ✅

@mikkamp mikkamp merged commit 4cb36d5 into develop Oct 25, 2023
11 checks passed
@mikkamp mikkamp deleted the tweak/2130-track-campaign-count branch October 25, 2023 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: tweak Small change, that isn't actually very important.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Campaign Count Tracking
2 participants