File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2799,6 +2799,28 @@ if (typeof window.Matomo !== 'object') {
27992799 return false ;
28002800 }
28012801
2802+ /**
2803+ * Returns if the current landing URL contains campaign-style parameters that should be treated as AI assistant sources.
2804+ * This covers cases where AI assistants append values like utm_source=chatgpt.com without sending a document referrer.
2805+ *
2806+ * @param currentUrl
2807+ * @returns {boolean }
2808+ */
2809+ function shouldIgnoreCampaignForCurrentUrl ( currentUrl ) {
2810+ var i ,
2811+ campaignParameterValue ;
2812+
2813+ for ( i = 0 ; i < configCampaignNameParameters . length ; i ++ ) {
2814+ campaignParameterValue = getUrlParameter ( currentUrl , configCampaignNameParameters [ i ] ) ;
2815+
2816+ if ( campaignParameterValue . length && shouldIgnoreCampaignForReferrer ( campaignParameterValue ) ) {
2817+ return true ;
2818+ }
2819+ }
2820+
2821+ return false ;
2822+ }
2823+
28022824 /*
28032825 * Removes hash tag from the URL
28042826 * Removes ignore_referrer/ignore_referer
@@ -3968,7 +3990,8 @@ if (typeof window.Matomo !== 'object') {
39683990 if ( ( ! configConversionAttributionFirstReferrer
39693991 || ! campaignNameDetected . length )
39703992 && ( configEnableCampaignParameters || configConsentRequired )
3971- && ! shouldIgnoreCampaignForReferrer ( configReferrerUrl ) ) {
3993+ && ! shouldIgnoreCampaignForReferrer ( configReferrerUrl )
3994+ && ! shouldIgnoreCampaignForCurrentUrl ( currentUrl ) ) {
39723995 for ( i in configCampaignNameParameters ) {
39733996 if ( Object . prototype . hasOwnProperty . call ( configCampaignNameParameters , i ) ) {
39743997 campaignNameDetected = getUrlParameter ( currentUrl , configCampaignNameParameters [ i ] ) ;
Original file line number Diff line number Diff line change @@ -3769,7 +3769,7 @@ function generateAnIframeInDocument() {
37693769 });
37703770
37713771 test("tracking", function() {
3772- expect(189 );
3772+ expect(192 );
37733773
37743774 // Prevent Opera and HtmlUnit from performing the default action (i.e., load the href URL)
37753775 var stopEvent = function (evt) {
@@ -4283,6 +4283,15 @@ function generateAnIframeInDocument() {
42834283 equal(attributionInfos[1], ['']);
42844284 equal(attributionInfos[3], ['https://chatgpt.com/c/683cd223-11f8-8r0c-a463-9b0606688162']);
42854285
4286+ icTracker.deleteCookies();
4287+ icTracker.setReferrerUrl('');
4288+ icTracker.setCustomUrl('https://matomo.org/blog/?utm_source=chatgpt.com');
4289+ icTracker.trackPageView('ignoreCampaignNoReferrer');
4290+ attributionInfos = icTracker.getAttributionInfo();
4291+ equal(attributionInfos[0], ['']);
4292+ equal(attributionInfos[1], ['']);
4293+ equal(attributionInfos[3], ['']);
4294+
42864295 // delete existing onerror handler and setup tracking again
42874296 window.onerror = customOnErrorInvoked = false;
42884297 tracker2.enableJSErrorTracking();
You can’t perform that action at this time.
0 commit comments