Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Google Analytics for AS2

Explorer ,
May 12, 2009 May 12, 2009

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

TOPICS
ActionScript
10.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , May 12, 2009 May 12, 2009

http://blog.circlecube.com/2008/01/28/integrate-google-analytics-with-flash-tutorial/

Translate
Community Expert ,
May 12, 2009 May 12, 2009

http://blog.circlecube.com/2008/01/28/integrate-google-analytics-with-flash-tutorial/

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 12, 2009 May 12, 2009

kglad,

You are the best!!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 12, 2009 May 12, 2009

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 18, 2009 May 18, 2009

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 18, 2009 May 18, 2009

copy and paste logging.as

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 18, 2009 May 18, 2009

//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;
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 18, 2009 May 18, 2009

and did you add the ga javascript with your ua number to your html page?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 18, 2009 May 18, 2009

yes, I did.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 18, 2009 May 18, 2009

<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>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 18, 2009 May 18, 2009

that's not your ua number.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 18, 2009 May 18, 2009

I didn't think I should post the actual number...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 18, 2009 May 18, 2009

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 18, 2009 May 18, 2009

UA-3607438-1

Does the number help you help me? 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 18, 2009 May 18, 2009

no, it doesn't.

what problem do you see?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 18, 2009 May 18, 2009

I am not receiving any Analytics... the pages are not showing up through the Google Analytics.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 18, 2009 May 18, 2009

has it been 48 hours since you started testing?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 18, 2009 May 18, 2009

It has been 5-6 days.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 18, 2009 May 18, 2009

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");
};

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 18, 2009 May 18, 2009

the first 2 paramenters in trackGA() are always required but you're not always sending 2 parameters.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 19, 2009 May 19, 2009

I'm not sure what you mean...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 19, 2009 May 19, 2009

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 19, 2009 May 19, 2009


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... 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 19, 2009 May 19, 2009

sometimes your using:

trackGA("button/pressed/video");

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 19, 2009 May 19, 2009

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines