Keyword

Track attachment downloads by country?

  • Brian
  • Brian's Avatar Topic Author
  • Offline
  • Junior Member
More
8 years 10 months ago #150840 by Brian
Hi,

Is there a way - either via a K2 component, or Google Analytics, to track attachment downloads by country? I am trying to figure out the most painless way to implement this.

Thanks!
Brian

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 10 months ago #150852 by Krikor Boghossian
Replied by Krikor Boghossian on topic Track attachment downloads by country?
The easiest way would be to add an analytics event to the link to track it through your analytic's account.

The code that generates the link in item.php is:
<a title="<?php echo K2HelperUtilities::cleanHtml($attachment->titleAttribute); ?>" href="<?php echo $attachment->link; ?>"><?php echo $attachment->title; ?></a>

I suggest that you use overrides instead of editing core files.
getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Brian
  • Brian's Avatar Topic Author
  • Offline
  • Junior Member
More
8 years 10 months ago #150870 by Brian
Replied by Brian on topic Track attachment downloads by country?
I tried adding the event tracking info to the url, based on this site's instructions: www.blastam.com/blog/index.php/2011/04/how-to-track-downloads-in-google-analytics

But when I add the code (for case when same window), I get a 404 error on my site. Any ideas?

Thanks! Brian

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 10 months ago #150872 by Krikor Boghossian
Replied by Krikor Boghossian on topic Track attachment downloads by country?
This blog post seems a bit old. Depending on which version of analytics you are using (ga.js or analytics.js) you should consult Google's documentation.
developers.google.com/analytics/devguides/collection/analyticsjs/events

or
developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide?hl=en

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Brian
  • Brian's Avatar Topic Author
  • Offline
  • Junior Member
More
8 years 10 months ago #150891 by Brian
Replied by Brian on topic Track attachment downloads by country?
Hi,

I changed the code to the following, after reviewing recent info:
<a title="<?php echo K2HelperUtilities::cleanHtml($attachment->titleAttribute); ?>" href="<?php echo $attachment->link; ?>" onClick="_gaq.push(['_trackEvent', 'Downloads', 'Click', 'Downloads','0']);"><?php echo $attachment->title; ?></a>

And I am using the plugin Nice Google Analytics, which simply loads google analytics (async).

But the event is not being created. Do you see anything obvious that is going wrong?

thanks!
Brian

Please Log in or Create an account to join the conversation.

More
6 years 9 months ago #166447 by natecovington
Replied by natecovington on topic Track attachment downloads by country?
This is the onClick command that I recently used for a client's site using the new Universal Analytics tracking code, Joomla 3.8.x, K2 2.8.x:
onclick="ga('send', 'event', 'PDF', 'Download', '<?php echo $attachment->filename; ?> <?php echo $attachment->title; ?>');"

Hope this is helpful for someone...

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
6 years 9 months ago #166452 by Krikor Boghossian
Replied by Krikor Boghossian on topic Track attachment downloads by country?
You posted it again, thanks :)

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum