Skip to content

Instantly share code, notes, and snippets.

@NathanQ
Created December 27, 2013 21:50
Show Gist options
  • Save NathanQ/8153140 to your computer and use it in GitHub Desktop.
Save NathanQ/8153140 to your computer and use it in GitHub Desktop.
just a django template. If you use django filer / github.com/stefanfoulis/django-filer and google analytics on your web site and want to see those file clicks on the analytics reports, use this trackable link template. (formatting for legibility)
{% if object.file.url %}
<a href="{{ object.file.url }}" onclick="_gaq.push(['_trackEvent', 'File Downloads', 'Downloaded', '{{ object.file }}']);">
{% if object.title %}
{{ object.title|safe }}
{% else %}
<img src="{% file_icon object %}" alt="Download File" />
{% endif %}
</a>
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment