Copy link to clipboard
Copied
Hi,
I created a web site in Actionscript 2 and have been asked to add Google Analytics to it. This is the first person who has asked me to do this and when I log into Google Analytics, they only provide the code for Actionscript 3. Apparently there used to be just Actionscript 2 code there but for a while it has just been AS3. I am told that the old code still works and I know that someone out there must have it. Can anyone help me out with it?
Thank you,
-Jan
http://blog.circlecube.com/2008/01/28/integrate-google-analytics-with-flash-tutorial/
Copy link to clipboard
Copied
http://blog.circlecube.com/2008/01/28/integrate-google-analytics-with-flash-tutorial/
Copy link to clipboard
Copied
kglad,
You are the best!!!
Copy link to clipboard
Copied
you're welcome.
Copy link to clipboard
Copied
Hi,
I am not seeing any results from using the code from the blog. My navigation code looks like this:
import flash.external.*;
#include "logging.as"
bt_video.onRelease = function() {
trackGA("swfLoaded");
unloadMovieNum (2);
unloadMovieNum (3);
unloadMovieNum (4);
unloadMovieNum (8);
unloadMovieNum (10);
loadMovieNum ("AS2MR_bio.swf",2);
loadMovieNum ("AS2MR_bioWRD.swf",3);
loadMovieNum ("AS2MR_BOTNAV_02.swf",7);
};
I used the .as file that they had to download using my tracking code number and I included the code within the html page that they recommended.
Thanks,
-Jan
Copy link to clipboard
Copied
copy and paste logging.as
Copy link to clipboard
Copied
//trackGA (categoryOrPageTrack [required], action [required], label [optional], value [optional]
//categoryOrPageTrack - either the category string or a string saying 'page'
function trackGA(categoryOrPageTrack:String, action:String, optional_label:String, optional_value:Number) {
//call page tracking version of Google analytics
if (categoryOrPageTrack == "page") {
//trace("GATC pageTracker call");
trackGAPage(action);
}
//call event tracking method
else {
//trace("GATC event tracker call");
trackGAEvent(categoryOrPageTrack, action, optional_label, optional_value);
}
}
var prefix:String = "flashGA";
//Google Analytics Calls Page Tracking - for tracking page views
function trackGAPage(action:String) {
//GA call
if (prefix != null && !eventTrack){
var call = "/" + prefix + "/" + action;
//Old Google Analytics Code (urchinTracker)
ExternalInterface.call("urchinTracker('"+call+"')");
//New Google Analytics Code (_trackPageview) pageview
ExternalInterface.call("pageTracker._trackPageview('"+call+"')");
trace("==GATC==pageTracker._trackPageview('"+call+"')");
}
_root.tracer.text = action;
}
//Google Analytics Event Tracking Calls - for tracking events and not pageviews
//category, action, label (optional), value(optional)
function trackGAEvent(category:String, action:String, optional_label:String, optional_value:Number) {
/*
objectTracker_trackEvent(category, action, optional_label, optional_value)
category (required) - The name you supply for the group of objects you want to track.
action (required) - A string that is uniquely paired with each category, and commonly used to define the type of user interaction for the web object.
label (optional) - An optional string to provide additional dimensions to the event data.
value (optional) - An optional integer that you can use to provide numerical data about the user event.
*/
theCategory = "'" + category;
theAction = "', '" + action + "'";
theLabel = (optional_label == null) ? "" : ", '" + optional_label + "'";
theValue = (optional_value == null) ? "" : ", " + optional_value;
//New Google Analytics Code (_trackEvent) event tracking
theCall = "pageTracker._trackEvent(" + theCategory + theAction + theLabel + theValue + ")";
ExternalInterface.call(theCall);
trace("====GATC===="+theCall);
_root.tracer.text = theCategory + theAction + theLabel + theValue;
}
Copy link to clipboard
Copied
and did you add the ga javascript with your ua number to your html page?
Copy link to clipboard
Copied
yes, I did.
Copy link to clipboard
Copied
<SCRIPT type=text/javascript>
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</SCRIPT>
<SCRIPT type=text/javascript>
var pageTracker = _gat._getTracker("UA-########");
pageTracker._initData();
pageTracker._trackPageview();
</SCRIPT>
<script language="javascript">AC_FL_RunContent = 0;</script>
<script src="AC_RunActiveContent.js" language="javascript"></script>
Copy link to clipboard
Copied
that's not your ua number.
Copy link to clipboard
Copied
I didn't think I should post the actual number...
Copy link to clipboard
Copied
ok. (but your number is public information - anyone that loads your html page in a browser can view your ua number.)
so, what problem do you see?
Copy link to clipboard
Copied
UA-3607438-1
Does the number help you help me?
Copy link to clipboard
Copied
no, it doesn't.
what problem do you see?
Copy link to clipboard
Copied
I am not receiving any Analytics... the pages are not showing up through the Google Analytics.
Copy link to clipboard
Copied
has it been 48 hours since you started testing?
Copy link to clipboard
Copied
It has been 5-6 days.
Copy link to clipboard
Copied
The complete code for the top navigation:
import flash.external.*;
#include "logging.as"
btn_logo2.onRelease = function() {
trackGA("page","swfLoaded");
unloadMovieNum (2);
unloadMovieNum (3);
unloadMovieNum (4);
unloadMovieNum (7);
unloadMovieNum (10);
loadMovieNum ("AS2MR_home.swf",2);
loadMovieNum ("AS2MR_homeWRD.swf",3);
loadMovieNum ("AS2MR_BOTNAV_01.swf",8);
trackGA("button/pressed/home");
};
btn_home.onRelease = function() {
trackGA("page","swfLoaded");
unloadMovieNum (2);
unloadMovieNum (3);
unloadMovieNum (4);
unloadMovieNum (7);
unloadMovieNum (10);
loadMovieNum ("AS2MR_home.swf",2);
loadMovieNum ("AS2MR_homeWRD.swf",3);
loadMovieNum ("AS2MR_BOTNAV_01.swf",8);
trackGA("button/pressed/home");
};
btn_video.onRelease = function() {
trackGA("page","swfLoaded");
unloadMovieNum (2);
unloadMovieNum (3);
unloadMovieNum (4);
unloadMovieNum (7);
unloadMovieNum (10);
loadMovieNum ("AS2MR_videos.swf",2);
loadMovieNum ("AS2MR_BOTNAV_01.swf",8);
trackGA("button/pressed/video");
}
btn_work.onRelease = function() {
trackGA("page","swfLoaded");
unloadMovieNum (2);
unloadMovieNum (3);
unloadMovieNum (4);
unloadMovieNum (7);
unloadMovieNum (10);
loadMovieNum ("AS2MR_work.swf",2);
loadMovieNum ("AS2MR_workWRD.swf",3);
loadMovieNum ("AS2MR_BOTNAV_01.swf",8);
trackGA("button/pressed/work");
}
btn_bio.onRelease = function() {
trackGA("page","swfLoaded");
unloadMovieNum (2);
unloadMovieNum (3);
unloadMovieNum (4);
unloadMovieNum (8);
unloadMovieNum (10);
loadMovieNum ("AS2MR_bio.swf",2);
loadMovieNum ("AS2MR_bioWRD.swf",3);
loadMovieNum ("AS2MR_BOTNAV_02.swf",7);
trackGA("button/pressed/bio");
};
Copy link to clipboard
Copied
the first 2 paramenters in trackGA() are always required but you're not always sending 2 parameters.
Copy link to clipboard
Copied
I'm not sure what you mean...
Copy link to clipboard
Copied
This is how the GA is seeing the Flash portion of the website right now:
1. /
2. /pageTracker/IntegrateGoogleAnalytics/swfLoaded
3. /flashGA/swfLoaded
4. /?msclkid=949bcffc4d815a498c4815d315ae59d7&mscbg=0
Copy link to clipboard
Copied
The blog that you sent was updated at this link:
http://blog.circlecube.com/2008/10/03/event-tracking-with-google-analytics-flash-integration-tutorial/
They summarize the string for tracking:
_trackEvent(category, action, optional_label, optional_value)
category:string (required)
This is the name of the object you are tracking.
action:string (required)
This is the action that happens to your object you want to track.
optional_label:string (optional)
This can be more information to accompany the action.
optional_value:integer (optional)
A number to provide numerical information to accompany the action.
I followed the steps they posted but I'm missing some key element. Some basic piece of information is not penetrating my head...
I downloaded the sample files and that confused me further... I'm pathetic...
Copy link to clipboard
Copied
sometimes your using:
trackGA("button/pressed/video");
Copy link to clipboard
Copied
Doesn't that translate as an optional label?
(_trackEvent(category, action, optional_label, optional_value)
I thought that there was an option to do that... am I misunderstanding the string that was supplied?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now