Skip to content

Commit

Permalink
Add source to tracked parameters #27
Browse files Browse the repository at this point in the history
  • Loading branch information
electerious committed Dec 31, 2020
1 parent 60ff500 commit 293fe34
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,26 @@ const isFakeId = function(id) {

}

/**
* Get ref, source or utm_source parameter.
* @returns {String} source
*/
const source = function() {

const searchValue = (key) => (location.search.split(`${ key }=`)[1] || '').split('&')[0]

const ref = searchValue('ref')
const src = searchValue('source')
const utm = searchValue('utm_source')

if (ref !== '') return ref
if (src !== '') return src
if (utm !== '') return utm

return undefined

}

/**
* Gathers all platform-, screen- and user-related information.
* @param {Boolean} detailed - Include personal data.
Expand All @@ -65,7 +85,8 @@ export const attributes = function(detailed = false) {

const defaultData = {
siteLocation: window.location.href,
siteReferrer: document.referrer
siteReferrer: document.referrer,
source: source()
}

const detailedData = {
Expand Down

0 comments on commit 293fe34

Please sign in to comment.