Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update fbclid_catcher.js #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions fbclid_catcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,44 @@ var fbp = cookies._fbp
var ua = window.navigator.userAgent
history.pushState({}, null, queryString+'&fbclid='+fbclick_final+'&fbp='+fbp+'ua'+ua);
}


For Google Tag manaer

<script>

if (window.location.href.indexOf('fbclid') > 0) {
console.log('Clickid is present url '+ window.location.href.indexOf('fbclid'))

} else {
var queryString = window.location.search;
var allCookies = document.cookie.split(';').map(function (cookie) {
return cookie.split('=');
})
.reduce(function (cookies, line) {
cookies[line[0].trim()] = line[1]
return cookies;
}, {});


console.log('ALL COOKIES ++++++++++++++++++++', allCookies)

var fbclick = allCookies._fbc;
console.log('fbclick', fbclick)

var fbclick_final = fbclick.slice(19);

console.log('fbclick_final', fbclick_final)
var fbp = allCookies._fbp;
var ua = window.navigator.userAgent;

var fbclid= fbclick_final+'&fbp='+fbp+'ua'+ua

console.log('FINAL FBCLID', fbclid)
history.pushState({}, null, queryString+'&fbclid='+fbclid);
}
</script>