Last active
March 3, 2025 16:14
-
-
Save robisatthefunction/e25d92c365cdb724388d56b9daca1e7c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
async function checkIPAddress() { | |
// Using a public IP API service to get the visitor's IP | |
const response = await fetch('https://api.ipify.org?format=json'); | |
const data = await response.json(); | |
const visitorIP = data.ip; | |
return visitorIP | |
} | |
window.optimizely = window.optimizely || []; | |
window["optimizely"].push({ | |
"type": "holdEvents" | |
}); | |
(() => { | |
var excludedIPs = ['225.37.219.110', '198.94.96.31', '198.94.96.31']; | |
var visitorIP = checkIPAddress(); | |
// If not in the excluded list of IPs, send Optimizely events | |
if (!excludedIps.includes(visitorIP)) { | |
window["optimizely"].push({ | |
"type": "sendEvents" | |
}); | |
console.log("Optimizely Web events sent"); | |
} else { | |
console.log(" Optimizely Web events disabled"); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment