Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

542 B
Raw Blame
import { useEffect } from "react";

export function useRemoveGAParams() {
  useEffect(() => {
    const url = new URL(window.location.href);
    if (url.searchParams.has("_gl")) {
      // Wait for GA to process (typical GA initialization takes ~100-500ms)
      // Adding buffer time to be safe
      setTimeout(() => {
        url.searchParams.delete("_gl");
        // Use replaceState instead of router.replace to avoid triggering a re-render
        window.history.replaceState({}, "", url.toString());
      }, 2000);
    }
  }, []);
}