Support community for TTG plugins and products.
NOTICE
The Turning Gate's Community has moved to a new home, at https://discourse.theturninggate.net.
This forum is now closed, and exists here as a read-only archive.
You are not logged in.
Pages: 1
Hello,
Just wondering if there is any way I can set up the Gallery to register it as a goal when one of the images is downloaded?
Many Thanks,
Trav.
Offline
what are the requirements?
Rod
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site
Offline
So what i was looking at was integration with the google analytics tracking. At the moment the number of visitors and so on is tracked, but I am wondering if there is any way to track the number of times images are downloaded using the Gallery system, so I can see which images are most downloaded or most popular etc.
I believe you can set up goals in Google analytics, but I don't believe it is tracking when a file is downloaded, is it possible to do that?
Offline
The TTG BE database doesn't keep track of downloads. Maybe if you put some tracking code into the PHP script that initiates the file download, but that's beyond me and not something I'm keen to research right now.
Offline
Thanks Matthew,
Which is the PHP script that I would look at editing that initiates the file download?
From what I can see it does appear to be feasable, using the below example:
<a href=”http://www.abc.com/gu/dw/social-media-guide.pdf” onClick=”ga(‘send’, ‘event’, ‘guides’, ‘download-social’, ‘social-media-guide.pdf’, 10);“>Download Social Media Guide</a>
If you can point me in the direction of the download PHP script, I can have a look at doing an edit. Many thanks!
Offline
Offline
I didn't have much luck, tried adding the following into the Download.php file but it never really worked (with my own UA code).
Not sure if anyone else in the community is keen to give it a go but code is below if they are.
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxx-6']);
_gaq.push(['_trackEvent', 'Downloads', 'Photos', $filename]);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
Offline
Well, you cannot simply slap Javascript into a PHP file and expect it to run. I'm not familiar enough with Google's ever-changing API to know whether there's a good PHP-based solution for this.
Offline
Thanks Matt, I don't think it will work this way either (i had tried the echo).
There is not a PHP solution (official) to my knowledge, but I think the biggest issue is the download.php is actually forcing it to download the file rather than display, so I don't think the script will ever properly fire.
I had a look at the actual gallery part, and I could make the potential change below but I am having cache issues and it goes not show up from what I can see, no biggie as I can leave it for the future. It was a nice to have to know who is downloading what and which are the most popular images, but is not the end of the world not having it.
.delegate(".mfp-download a","click", function(e){
e.preventDefault();
ga(‘send’, ‘event’, ‘Downloads’, albumURL, currentImage);
window.location.href = albumURL + "download.php?file=photos/" + currentImage + ".jpg";
})
Offline
Pages: 1