The first thing to do is to fill the site with content: add all the necessary pictures and captions. After everything is ready, turn on the developer mode. To do this, press the button as on the screenshot below:
At the bottom you get a code editor, go to it:
Highlight ALL the code that is there and paste ours in its place:
import wixLocation from 'wix-location';
$w.onReady(function () {
function getParametersAsString(url) {
return url.substring(url.indexOf("?"), url.length)
}
//Start of the image click handler
$w('#image1').onClick((event) => {
wixLocation.to("https://google.com" + getParametersAsString(wixLocation.url));
});
//End of handler
});
Check carefully that you have copied everything correctly! Especially if you are on a MAC! Check that the quotation marks look like quotation marks and not quot!!!!!
Now let's see what is the name of our image, which we have inserted on the page and which will be clicked by users. To do this, we click on the image and see that it has its name in the top corner. In this case, image3.
You will most likely have an image image1
if it is not, then fix the line in the code. image1
to your image title.
If you have a button rather than an image, then fix image1 to button1 or whatever it's called. If you have several buttons or images, copy the code between the lines "Handler start - Handler end" and paste them as many times as you need (according to the number of buttons and/or images). Write a different button/image ID in each of the pasted pieces of code.
The last step is to change in the code https://google.com to your campaign link in Keitaro WITHOUT the long tail of tags.
Publish our site in Vix with the button Publish.
Vix gives us a link to the site. Copy it!
Paste the link into your browser and add any sub-tags to the end of it. For example: https://rattack5.wixsite.com/mysite?sub1=abc&sub2=345
And press enter. Our site opens. Clicking on the picture should now take us to the campaign tracker: http://example.com?sub1=abc&sub2=345
Bonus: adding autoredirect with cloaking
We can determine by UserAgent who came to us. If it's a Facebook bot, we leave it on our page, if it's a regular user, we can automatically redirect it to the offer. In the example below, the auto redirect happens after 300 ms.
import wixLocation from 'wix-location';
function getParametersAsString(url) {
return url.substring(url.indexOf("?")+1, url.length);
}
function isFacebookBot() {
var userAgent = navigator.userAgent.toLowerCase();
return userAgent.includes('facebook') || userAgent.includes('facebot');
}
let dest = "https://example.com?" + getParametersAsString(wixLocation.url);
if (!isFacebookBot()) setTimeout(() => { wixLocation.to(dest); }, 300));
$w.onReady(function () {
$w("#image1").onClick((event) => {
wixLocation.to(dest);
});
//End of handler
});