let I am having the Text Link. so what should I do so that i can know how many times the link clicked?
I just want to know how can I get the total clicks of link...
whether its button or text...

This feature is available in softpedia. while clicking download button.

Dani AI

Generated

— since you’re on Weebly and don’t have your own server, a small client-side counter plus a redirect is the quickest way to both track and show downloads. was correct that Google Analytics is great for tracking events, but GA alone won’t give a simple live badge next to the button without extra backend work. Two practical options follow: a lightweight public counter you can embed now, or a slightly more robust server/serverless redirect for authoritative counts.

A simple, embeddable option is CountAPI (a public increment/get API). Place an Embed Code element in Weebly with a button and a span for the count. On page load call the get endpoint to show the current value; on click call the hit endpoint to increment, update the span, then continue to the download URL. Example (replace namespace, key, and downloadUrl):

<button id="dlBtn">Download</button>
<span id="dlCount">0</span>

<script>
const btn = document.getElementById('dlBtn');
const countEl = document.getElementById('dlCount');
const ns = 'your-namespace';
const key = 'your-key';
const downloadUrl = 'https://example.com/file.zip';

fetch(`https://api.countapi.xyz/get/${ns}/${key}`)
  .then(r => r.json()).then(d => countEl.textContent = d.value).catch(()=>{});

btn.addEventListener('click', function(e){
  e.preventDefault();
  const hit = fetch(`https://api.countapi.xyz/hit/${ns}/${key}`);
  const timeout = new Promise((_,rej)=>setTimeout(()=>rej('timeout'),1000));
  Promise.race([hit, timeout])
    .then(r => r.json())
    .then(d => { countEl.textContent = d.value; })
    .catch(()=>{})
    .finally(()=> window.location = downloadUrl);
});
</script>

Cautions and alternatives: CountAPI is public and easy to game (bots, repeated reloads). For reliable, tamper-resistant counts use a server/serverless function (Netlify/Vercel/AWS Lambda) that logs the hit to a database then issues a 302 redirect to the file. Point the button to that redirect URL; the server-side approach also lets you filter bots and store metadata. If you only need analytics, use GA4 event tracking for reports (developers.google.com/analytics/devguides/collection/gtagjs/events). For a quick visible badge plus detailed analytics use the embeddable counter for display and GA for analysis (both can run together).

CountAPI:
GA4 event docs: https://developers.google.com/analytics/devguides/collection/gtagjs/events

Recommended Answers

All 3 Replies

There are a few ways to handle this. Are you running anything server side that can assist you with handling events? How about client side? Maybe use javascript and Ajax so that when a user clicks on a link, you fire an event then send data back to a page on your site that can handle the data and store the info in a DB table.

I am not familar with the web designing...
but yes, I can just say you simple thing that I am doing...
I use the Web site Builder site i.e. weebly.
What I want ?
I add the button from toolbox and I can add the link to it. (but I can't handle new condition)
But yes I can do it embedded code. i.e. I can create button with html and so on, but the thing is that How I can handle two condition on a same link/button.

For example: here is the button X name: download. and that related with the download link for X software, but I also want to place the button which shows total download (label) below the X button.

Example: Softpedia.
You can view my site so if you get some hints.?

So, it sounds like you are limited in what you can implement on the site. Here is a possible solution for you. Use Google Analytics to track this. This solution only requires the ability to place javascript/jQuery code on your pages.

http://www.blastam.com/blog/index.php/2013/03/how-to-track-downloads-in-google-analytics-v2/

This won't give you the ability to place the number of downloads next to the button but will let you track it.

If you want to display the number on your site, you will either have to store the number in a DB table and write the code to update and query or you will have to find a service on the web that will allow you to use javascript to send back and retrieve the data upon clicking the button and/or page load.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.