Skip to content

Add custom context in the link click

What does this MR do and why?

This MR adds custom context in the link click.

Ref - https://gitlab.com/gitlab-data/analytics/-/issues/23219#note_2393748239

References

How to set up and validate locally

  1. Enable snowplow micro [doc]
  2. Apply this patch to enable link click in GDK
diff --git a/app/assets/javascripts/tracking/index.js b/app/assets/javascripts/tracking/index.js
index 50cd6f2d61d6..041a27bc09e6 100644
--- a/app/assets/javascripts/tracking/index.js
+++ b/app/assets/javascripts/tracking/index.js
@@ -62,12 +62,10 @@ export function initDefaultTrackers() {
     Tracking.enableFormTracking(opts.formTrackingConfig);
   }
 
-  if (window.snowplowOptions.linkClickTracking) {
-    window.snowplow('enableLinkClickTracking', {
-      pseudoClicks: true,
-      context: [standardContext, ...experimentContexts],
-    });
-  }
+  window.snowplow('enableLinkClickTracking', {
+    pseudoClicks: true,
+    context: [standardContext, ...experimentContexts],
+  });
 
   Tracking.flushPendingEvents();
  1. Install snowplow plugin.
  2. Before this change, link click was not sending standard context.
  3. Click on the GitLab logo on top left corner.
  4. Verify that standard context is captured.

Screenshot_2025-03-13_at_9.44.37_AM

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Ankit Panchal

Merge request reports

Loading