Hello, I’m new to Wix and this might be a basic question but I haven’t found an easy answer yet. I’m building a link aggregator site where I hope to sell advertising space to other companies. I need to track how many times my site’s visitors click on the links that lead to those advertiser’s sites. For instance, I want to know how many times within a given timeframe the link for www.CompanyX.com was clicked so that I can tell Company X how much traffic I’m sending to their website. I’ve already installed Google Analytics on the site, and I’ve tried to figure out Google Tag Manager but that seems considerably more complicated. Can I get the information I need just from Google Analytics? Or is there some other way to track how many times a button or link is clicked on my website?
Thank you–
Can someone please respond to this? Did you ever get a solution?
Hello Mario,
if you need just a simple counter, which counts all the clicks of a pressed button, then you can make it by your own, creating a counter.
It would work like this…
-
When BUTTON1 clicked —> set myCounter = myCounter (+1)
$w.onReady(function () { }
var myCounter
export function BUTTON1_click(event) {
myCounter = myCounter+1
console.log(myCounter)
}
When site is published, open it in google-chrome and press F-12.
Then go to console, run the code and see the result.
DO NOT FORGET TO CONNECT YOUR BUTTON WITH YOUR CODE!
You can see on the main-page of this website, how the following CODE is counting all the clicks…
https://russian-dima.wixsite.com/meinewebsite
function count_totalViews () {
let x = $w('#dataset1').getTotalCount()
$w("#dataset1").getItems(0, x)
.then((results) => {
let items = results.items;
let totalViews = 0
for (var i = 0; i < x; i++) {
// console.log(items[i].views)
totalViews = totalViews+Number(items[i].views)
}
console.log(totalViews)
$w('#TXTtotalviews').text= totalViews.toString()
})
}