Community @ The Turning Gate

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.

  • New user registrations are disabled.
  • Users cannot create new topics.
  • Users cannot reply to existing topics.

You are not logged in.

#1 2015-05-20 10:56:32

trav.d.hale
Member
Registered: 2015-04-28
Posts: 45

Google Analytics Goal

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

#2 2015-05-21 22:48:07

rod barbee
Moderator
From: Port Ludlow, WA USA
Registered: 2012-09-24
Posts: 17,830
Website

Re: Google Analytics Goal

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

#3 2015-05-24 17:37:08

trav.d.hale
Member
Registered: 2015-04-28
Posts: 45

Re: Google Analytics Goal

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

#4 2015-05-24 19:57:14

Matthew
Administrator
From: San Francisco, CA
Registered: 2012-09-24
Posts: 5,795
Website

Re: Google Analytics Goal

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.


Matt

The Turning Gate, http://theturninggate.net

Offline

#5 2015-05-25 15:52:34

trav.d.hale
Member
Registered: 2015-04-28
Posts: 45

Re: Google Analytics Goal

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

#6 2015-05-25 19:27:48

Matthew
Administrator
From: San Francisco, CA
Registered: 2012-09-24
Posts: 5,795
Website

Re: Google Analytics Goal

download.php


Matt

The Turning Gate, http://theturninggate.net

Offline

#7 2015-06-01 16:34:38

trav.d.hale
Member
Registered: 2015-04-28
Posts: 45

Re: Google Analytics Goal

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

#8 2015-06-01 17:32:45

Matthew
Administrator
From: San Francisco, CA
Registered: 2012-09-24
Posts: 5,795
Website

Re: Google Analytics Goal

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.


Matt

The Turning Gate, http://theturninggate.net

Offline

#9 2015-06-02 10:12:16

trav.d.hale
Member
Registered: 2015-04-28
Posts: 45

Re: Google Analytics Goal

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

Board footer

Powered by FluxBB