@@ -354,14 +354,28 @@ AmplitudeClient.prototype._migrateUnsentEvents = function _migrateUnsentEvents(c
354354 * @private
355355 */
356356AmplitudeClient . prototype . _trackParamsAndReferrer = function _trackParamsAndReferrer ( ) {
357+ let utmProperties ;
358+ let referrerProperties
359+ let gclidProperties ;
357360 if ( this . options . includeUtm ) {
358- this . _initUtmData ( ) ;
361+ utmProperties = this . _initUtmData ( ) ;
359362 }
360363 if ( this . options . includeReferrer ) {
361- this . _saveReferrer ( this . _getReferrer ( ) ) ;
364+ referrerProperties = this . _saveReferrer ( this . _getReferrer ( ) ) ;
362365 }
363366 if ( this . options . includeGclid ) {
364- this . _saveGclid ( this . _getUrlParams ( ) ) ;
367+ gclidProperties = this . _saveGclid ( this . _getUrlParams ( ) ) ;
368+ }
369+ if ( this . options . logAttributionCapturedEvent ) {
370+ const attributionProperties = Object . assign (
371+ { } ,
372+ utmProperties ,
373+ referrerProperties ,
374+ gclidProperties
375+ ) ;
376+ if ( Object . keys ( attributionProperties ) . length > 0 ) {
377+ this . logEvent ( Constants . ATTRIBUTION_EVENT , attributionProperties ) ;
378+ }
365379 }
366380} ;
367381
@@ -675,6 +689,7 @@ AmplitudeClient.prototype._initUtmData = function _initUtmData(queryParams, cook
675689 cookieParams = cookieParams || this . cookieStorage . get ( '__utmz' ) ;
676690 var utmProperties = getUtmData ( cookieParams , queryParams ) ;
677691 _sendParamsReferrerUserProperties ( this , utmProperties ) ;
692+ return utmProperties ;
678693} ;
679694
680695/**
@@ -739,6 +754,7 @@ AmplitudeClient.prototype._saveGclid = function _saveGclid(urlParams) {
739754 }
740755 var gclidProperties = { 'gclid' : gclid } ;
741756 _sendParamsReferrerUserProperties ( this , gclidProperties ) ;
757+ return gclidProperties ;
742758} ;
743759
744760/**
@@ -778,6 +794,7 @@ AmplitudeClient.prototype._saveReferrer = function _saveReferrer(referrer) {
778794 'referring_domain' : this . _getReferringDomain ( referrer )
779795 } ;
780796 _sendParamsReferrerUserProperties ( this , referrerInfo ) ;
797+ return referrerInfo ;
781798} ;
782799
783800/**
0 commit comments