Created
September 2, 2020 20:29
-
-
Save maestrojed/4992390b6083bb45db603be3694c45f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//get the current query string. | |
const urlParams = new URLSearchParams(window.location.search); | |
if( urlParams.has('source') && urlParams.has('medium') && urlParams.has('campaign') ) { | |
const source = urlParams.get('source'); | |
const medium = urlParams.get('medium'); | |
const campaign = urlParams.get('campaign'); | |
//Before ga("send", "pageview") | |
//if params were found. | |
ga('set', 'campaignSource', source); | |
ga('set', 'campaignMedium', medium); | |
ga('set', 'campaignName', campaign); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment