January 28, 2008 at 6:46 pm · 5,341 views · Filed under tutorial
The results are in and the requested topic is “Integrate Google Analytics into Flash.” The poll has been reset and is ready to recieve your post requests, so keep voting! It’s located in the side bar!
Overview:
Tracking your visitors and attempting to better understand them is a large part of even having content on the web. Since the days of visitor counters displayed proudly on every site, along with dozens of animated gifs to the days when site were designed solely with efficiency and conversion in mind. There are many services that will do this for a fee and other that will do it for free. A popular free web analytics tool is provided by Google. Google Analytics is started by including JavaScript on each page the user wishes to track. This JavaScript loads larger files from the Google webserver and then sets variables with the user’s account number. This JavaScript is used to track and log page views and visitors interaction with the site. This post discusses what to do if your site includes a lot of interactive flash elements you wish to track as well. With the little Google has published related to this(New Code, Old Code), I’ve tried to fill in.
Note: This explains how to set up to track flash events as page views, which does have a drawback- it inflates your pageviews in the analytics and in turn may skew your data. Il’l beposting again soon about how to use then new event tracking, which would track flash events not as pageviews, but as events and thus not inflate the page view count.
Steps:
If you haven’t already, install Google Analytics on your site. (Note that your analytics tracking code must be placed on the page above the flash call(s) to _trackPageview or urchinTracker)
Determine which events in flash you want to track.
Place in the external.interface code in your actionscript at the specific event(s).
Watch the events get logged in you Google Analytics Reports!
Example:
Here’s a simple example, say you want to track how many times an object is clicked or dragged by a user or how many times it bounces (something that could be tracked but doesn’t necessarily have any required user interaction). In this example flash file I have a ball which bounces off the walls and users can click to drag and even throw it, press the spacebar to create more balls and toggle the gravity on and off with the arrow keys (up is weightlessness, and down is gravity). Each of these events has code to communicate with Google Analytics JavaScript and track the events. I made my own function to call the google analytics code. Do I hear “but sometimes I want to use the new version of Google analytics, and sometimes I want to use the old one…” Have no fear, this function works for either one, or even both. If you’re not using the newer code the calls to the functions in the new code (pageTracker._trackPageview()) will be ignored and vice versa, if you are using the new code, then the calls to the functions in the old code (urchinTracker()) will be ignored, since the functions are not defined. You can track virtually anything with this method. I’ve exaggerated greatly in this example- just to show the variety of different ways this can be used. You might want to make certain the things you track will be useful and relevant for you.
Here is the swf file, I’ve added a text box that will print all actions that are logged to Google Analytics
Here is a screenshot of my Google Analytics Top Content after I search for “pageTracker/IntegrateGoogleAnalytics” (because I’m using the new code version, if I were using the old version I’d search for “urchin/IntegrateGoogleAnalytics”). This just shows that every event was logged to Google Analytics. This screenshot was taken mere hours after this post published.
Stay tuned for upcoming post about the new Event Tracking rather than posting each event you want to track in flash as a pageview it can be a specific event!
January 23, 2008 at 5:51 pm · 390 views · Filed under portfolio
Just added a poll plug-in to the site!
I’m polling readers to see what they want next, in regards to posts.
I have so many post drafts and even more post ideas and instead of letting them roll out in my usual leisurely fashion, I figured I’d let you prioritize them for me…
So vote in the poll to let me know what you want!
Feel free to contact me if you have any ideas that I haven’t listed yet. I enjoy knowing I’m writing for someone who is interested!
This poll is closed, and I’m working on the winning post! Integrating Google Analytics with Flash!
So keep posted, or subscribe to the RSS for immediate automatic free update.
I’ll keep a running poll in the side bar of the site so keep voting and suggesting your Most Wanted Posts!
January 21, 2008 at 7:19 pm · 1,762 views · Filed under tutorial
Overview:
Flash give publishers the opportunity to customize the right-click menu which pops up in the swf file with a context menu item in actionscript.
ContextMenuItem ContextMenuItem(caption:String, callbackFunction:Function, [separatorBefore:Boolean], [enabled:Boolean], [visible:Boolean])
Creates a new ContextMenuItem object that can be added to the ContextMenu.customItems array.
Steps:
The menu item has a caption, which is displayed to the user in the right click menu. It also has a a callback function handler by naming the function in the code to be invoked once the menu item is selected. It then has three boolean values which specify whether the item has a separator before it, is enabled, and is visible.
To add a new context menu item to a context menu, you simply create the context menu items and then push them into the customItems array.
You can enable or disable specific menu items, make items visible or invisible, or change the caption or callback handler associated with a menu item at any time.
In the example here the menu items about clearing and rewriting the text are set to toggle each other, so you can’t rewrite the text if it hasn’t yet been cleared and vice versa.
To further customize the context menu flash allows us to hide the built in items in the menu with hideBuiltInItems(). This hides all the built in item from view (except ’settings’) by setting their visibility to false.
Example:
Actionscript:
var myMenu:ContextMenu = newContextMenu();
myMenu.hideBuiltInItems();
var ccs:ContextMenuItem = newContextMenuItem("Visit Circle Cube Studio", visitCCS, false, true, true);
January 11, 2008 at 6:03 pm · 251 views · Filed under portfolio, work
About dot Stompernet dot Com (about.stompernet.com) is the new public (free) website from StomperNet. I helped implement this design and had to learn all about themes in Drupal. It’s still in beta, but it’s well on it’s way. It is an agglomeration site, where all the StomperNet Faculty’s feeds can be found and various other free content, like video in the Squambido player, and the Scrutinizer software.
January 11, 2008 at 6:00 pm · 575 views · Filed under portfolio, work
The new video player from StomperNet!
Feature Set: This Video Player is built in Adobe flash. I was involved in the actionscripting and design of the player and implementing many of the functions. There is a playlist imported into the player and even an html ’sales pages’ loaded into the player. The progress bar shows download progress, watched progress and even history. It shows you how far you’ve ever watched in each specific video in the playlist, the “high-water mark”, and it lets you jump back to that spot easily by clicking in the progress bar. A feature I’m proud of is the mute, it doesn’t just cut the audio, but has a fade to silent quality- which even remembers your preferred volume if you come back to the page later. The player incorporates google analytics. Full Screen mode allows use of the entire monitor. Another ‘tab’ is used to show info about the author.
There is a lot packed into this one player, and we have plans to pack in even more!
January 2, 2008 at 7:17 pm · 8,258 views · Filed under tutorial
Overview:
Many have struggled with the task of getting you swf to read or get the current url showing in the browser, the html page the browser is at which has the swf embedded. Not to be confused with the _root._url which returns the path of the swf file. This would be helpful to know if someone is embedding your swfs on their site, or even customize your swf depending on which page it resides on. There is a pretty simple, yet virtually undocumented way to do this. We have to use javascript by calling External Interface and get the url from the DOM. Window.location.href. Then we must call the toString() function only because ExternalInterface.call requires a function rather than only reading a static property.
Steps:
Import external interface into your file: import flash.external.ExternalInterface;
Initialize a variable to store the url path: var urlPath;
Create a function to call external interface and assign the html page path to your variable: urlPath = ExternalInterface.call(”window.location.href.toString”);
Call the function when/if needed.
Example:
With javascript: window.location.href or window.location.href.toString();
With actionscript: ExternalInterface.call(”window.location.href.toString”); External Interface html Example