How to track file downloads

I am launching an image gallery site that can be used to upload images ... let's say if you call somedomain.com/flowers it will return a zip file containing the top 10 floral images ....

Now my requirement is to track these downloads ... how can I implement this ... any opportunity to use Google Analytics.

Update: I forgot to add another important thing, because of which I can not use custom events ...

You don’t always have to click and download the zip file .... I created a small application (AIR application) to directly download the file. In this case, I can’t use the GA script ... I want to know if GA can be used in this case, if so, how to implement it?

+3
source share
3 answers

A user event fires when a user clicks on a download link.

0
source

( ), - " ". , ; , , trackPageview . , 100 :

js - a href, onclick , : ( , )

<script type="text/javascript">
  function obl(this) {
    try {
      var pageTracker=_gat._getTracker("UA-XXXXXXX-X");
      pageTracker._trackPageview("a_download_link");
      setTimeout('document.location = "' + this.href + '"', 100)
    }catch(err){}
}
</script>



<a href="a_download_link" onclick='obl(this);return false;'>Click Here to Download</a>


( GA), :

<script type="text/javascript">
  function obl(this) {
    _gaq.push(['_trackPageview', 'a_download_link'+this.href]);
    setTimeout('document.location = "' + this.href + '"', 100)
  }
</script>

, , , . , , - , "" . , GA, (, "" ), " ", , .

0

Source: https://habr.com/ru/post/1767342/


All Articles