You are not logged in.
Pages: 1
This tracks each album viewed in google analytics using the newer GA tracker, not the older urchin. This code is for ActionScript 3.
Further on I link to how to do it for galleries and images.
I figured it out with some trial and error, reading google's flash analytics info and looking at the API section of the wiki.
Here's how I got this to work.
Step one: Download Google Analytics for flash direct from google: http://code.google.com/p/gaforflash/
Step two: Follow the instructions in the readme.txt (from the zip you just downloaded) to get AnalyticsLibrary to appear in the components list of your FLA.
Step three: Start Flash again and open your FLA. Click on the components panel and you should see "Google". Expand it and you should see "Analytics" and AnalyticsLibrary".
Step four: Doubleclick "AnalyticsLibrary" to get it into your FLA.
Step five: Create a new layer above your movie and label it Google Analytics or whatever you want.
Step six: Click on that layer and go to window Actions and enter the following code(replace the UA-XXXXX with your code. Don't get rid of the quotes!):
import net.slideshowpro.slideshowpro.*;
import com.google.analytics.AnalyticsTracker;
import com.google.analytics.GATracker;
var tracker:AnalyticsTracker = new GATracker( this, "UA-XXXXXX", "AS3", true );
function onSlideShowData(event:SSPDataEvent) {
if (event.type=="albumData") {
trace("total images: " + event.data.title);
tracker.trackPageview("/"+event.data.title);
}
}
my_ssp.addEventListener(SSPDataEvent.ALBUM_DATA, onSlideShowData);Step six: Test it: Shortly after the UA code is the value: true. It means it's in debug mode. I suggest you leave it on and upload it to a testsite. It will show you what is being sent to google. It will appear in a yellow box at the top of the flash movie.
Step seven: Once you see that it's actually working and the value is what you want, just go back into your AS3 code and change it to false.
That should be it. Note: You probably don't need that trace line in there but I left it in just in case hehe.
Extra:
Let me explain the part of the code I think I understand in case you want to change it a bit.
The tracker.trackPageview("/"+event.data.title); outputs the album title with a / in front so in google analytics you'll see /people for example if people is the name of one of your albums. You can change the / to whatever. You can also put something else in quotes at the end so if you wanted, you could have tracker.trackPageview("The"+event.data.title+"album was visited") and if an album with the people title was clicked you'd see "The people album was visited" on google analytics page. It sends it to google as a gif file.
It all works by pulling the title off the albumdata event which I got from here:
http://wiki.slideshowpro.net/SSPfl/API- … -albumData
You can substitute whatever data object you want instead of title from the list on that wiki page.
If you want to track what galleries people go to use this page in the same way:
http://wiki.slideshowpro.net/SSPfl/API- … alleryData
Same for images data:
http://wiki.slideshowpro.net/SSPfl/API- … -imageData
Just copy and paste the examples there and add the tracker.trackPageview("/"+event.data.title) substituting one of the allowed data objects listed on those pages for the title.
Last edited by damado (2009-07-05 15:21:53)
Offline
Thanks I implemented this on my site and works great!
http://www.annelangdon.com/
Offline
great thanks
Offline
This is awesome! I noticed that when I change the event type to imageData that the tracker sends a hit to Google when the image is viewed. Is there any way to change it to where it just sends a hit if the image were clicked (Where that image would have a link assoicated with it)?
import net.slideshowpro.slideshowpro.*;
import com.google.analytics.AnalyticsTracker;
import com.google.analytics.GATracker;
var tracker:AnalyticsTracker = new GATracker( this, "UA-692258-24", "AS3", true );
function onSlideShowData(event:SSPDataEvent) {
if (event.type=="imageData") {
trace(event.data.link);
tracker.trackPageview("/"+event.data.link);
}
}
my_ssp.addEventListener(SSPDataEvent.IMAGE_DATA, onSlideShowData);Last edited by grantmx (2009-09-23 13:19:58)
Offline
Not much of a coder but hopefully I'll be able to make this work - thanks for supplying the info.
Just one question, can you add this information into the existing code above or do you have to do separate layers for the gallery code and image code?
If you want to track what galleries people go to use this page in the same way:
http://wiki.slideshowpro.net/SSPfl/API- … alleryData
Same for images data:
http://wiki.slideshowpro.net/SSPfl/API- … -imageData
Just copy and paste the examples there and add the tracker.trackPageview("/"+event.data.title) substituting one of the allowed data objects listed on those pages for the title.
Cheers
Irene
Offline
Google Analytics on Video Click
First of all thankyou damado for your great article on GA
I'm using SlideshowPro with ThumbGrid
Have AS3 code (below) working for src from the xml file
But would like to refine this more where GA tracks the (Hits) video play button when it is clicked
Hope someone can help with this
Thank you in advance
----------------------------------------------------
import net.slideshowpro.slideshowpro.*;
import com.google.analytics.AnalyticsTracker;
import com.google.analytics.GATracker;
var tracker:AnalyticsTracker = new GATracker( this, "UA-XXXXXX", "AS3", true );
function onSlideShowData(event:SSPDataEvent) {
if (event.type=="imageData") {
trace(event.data.src);
tracker.trackPageview("/"+event.data.src);
}
}
my_ssp.addEventListener(SSPDataEvent.IMAGE_DATA, onSlideShowData);
Offline
This is so helpful, thanks!
I'm just having one issue with conflicting AS3
flash is reporting this error
1021: Duplicate function definition. function onSlideShowData(event:SSPDataEvent) {
i already have this line within the code i'm using for external captions and titles.
I've tried to merge the 2 together but my AS3 is pretty weak!
Could you advise me how to stop the two bits of code conflicting??
Many thanks,
Andy
//External captions and text
import net.slideshowpro.slideshowpro.*;
import flash.external.ExternalInterface;
function onSlideShowData(event:SSPDataEvent) {
if (event.type=="imageData") {
var captionData=event.data.caption;
var titleData=event.data.title;
ExternalInterface.call("imageIden", captionData, titleData);
}
}
my_ssp.addEventListener(SSPDataEvent.IMAGE_DATA, onSlideShowData);//GA Tracker
import net.slideshowpro.slideshowpro.*;
import com.google.analytics.AnalyticsTracker;
import com.google.analytics.GATracker;
var tracker:AnalyticsTracker = new GATracker( this, "UA-#########", "AS3", true );
function onSlideShowData(event:SSPDataEvent) {
if (event.type=="albumData") {
trace("total images: " + event.data.title);
tracker.trackPageview("/"+event.data.title);
}
}
my_ssp.addEventListener(SSPDataEvent.ALBUM_DATA, onSlideShowData);Last edited by poblama (2010-01-23 03:43:07)
Offline
Virtsorrent wrote:
But would like to refine this more where GA tracks the (Hits) video play button when it is clicked
This can be done using the videoStart event.
function onVideoEvent(event:SSPVideoEvent) {
if (event.type=="videoStart") {
tracker.trackPageview("/your-link-here");
}
}
my_ssp.addEventListener(SSPVideoEvent.VIDEO_START, onVideoEvent);Last edited by annepautler (2010-02-24 13:26:20)
Offline
So when you say below you got it working with this code, you had changed "true" to "false" for AS3 when you deployed it, correct?
Did you also get it to work with the video event trigger?
Are you using Director hosting, (probably for another topic) but I have domain mapping installed with director hosting and wondered if there's another variable that has to be introduced. I'm currently waiting on GA to see if it logs anything.
Virtsorrent wrote:
Google Analytics on Video Click
First of all thankyou damado for your great article on GA
I'm using SlideshowPro with ThumbGrid
Have AS3 code (below) working for src from the xml file
But would like to refine this more where GA tracks the (Hits) video play button when it is clicked
Hope someone can help with this
Thank you in advance
----------------------------------------------------
import net.slideshowpro.slideshowpro.*;
import com.google.analytics.AnalyticsTracker;
import com.google.analytics.GATracker;
var tracker:AnalyticsTracker = new GATracker( this, "UA-XXXXXX", "AS3", true );
function onSlideShowData(event:SSPDataEvent) {
if (event.type=="imageData") {
trace(event.data.src);
tracker.trackPageview("/"+event.data.src);
}
}
my_ssp.addEventListener(SSPDataEvent.IMAGE_DATA, onSlideShowData);
Offline
I got this code to work, with AS3 flash, set the debug to false, I am using director on my own server. I have a unique page for each section of my site and each section has its own SSP instance, so I can track that it was loaded. I have not tied it to note when the video was played, so im not yet getting that data. I might try anne's code and see if it works. tricky part is it takes a day to see if the data is passed. so be patient when testing.
Best,
Slideshowpro fan
Offline
annepautler wrote:
Virtsorrent wrote:
But would like to refine this more where GA tracks the (Hits) video play button when it is clicked
This can be done using the videoStart event.
Code:
function onVideoEvent(event:SSPVideoEvent) { if (event.type=="videoStart") { tracker.trackPageview("/your-link-here"); } } my_ssp.addEventListener(SSPVideoEvent.VIDEO_START, onVideoEvent);
Can this be used WITH:
function onSlideShowData(event:SSPDataEvent) {
if (event.type=="albumData") {
trace("total images: " + event.data.title);
tracker.trackPageview("/"+event.data.title);
}
}
my_ssp.addEventListener(SSPDataEvent.ALBUM_DATA, onSlideShowData);or is it only possible to use 1 or the other?
Offline
This is a great thread. I have a site that uses a "baseplate" master swf and the individual swf load in the baseplate. I successfully added this code, but it send data to GA every time the slideshow changes pictures, which is not useful (eg, a user leaves the page open, walks away, and GA continues to count the slideshow images as they change).
I would like to have GA capture data when a user clicks an image on the Thumbgrid. I've tried to amend the code to include onclick events, but they don't contain any data and it simply does not work. Can someone please point me in the right direction?
The code works while testing in CS4, but when live I receive several 1009 errors.
import net.slideshowpro.slideshowpro.*;
import net.slideshowpro.thumbgrid.*;
import com.google.analytics.AnalyticsTracker;
import com.google.analytics.GATracker;
var tracker:AnalyticsTracker = new GATracker( this, "UA-XXXXXXX", "AS3", true );
function onSlideShowData(event: TGThumbEvent) {
if (event.type=="clickThumb") {
trace("Image: " + event.data.file);
tracker.trackPageview("/"+event.data.file);
}
}
my_tg.addEventListener(TGThumbEvent.CLICK_THUMB, onSlideShowData);
Last edited by orintas (2010-04-18 19:30:10)
Offline
Bump
Offline
Pages: 1