Add

AS3 Javascript Call Sequencer + Omniture + Google Analytics


Here's a little utility that I did for multiple Omniture calls to a javascript in the html page. It will also accept another call, such as an iFrame refresh. It delays each call a tiny bit to make sure that events are fired off. Also has a runtime environment detection so your browser window doesnt keep popping up during publishing. Source file below as well.

Usage:

_oSendJavascript = SendJavascript.getInstance();
// Genric Javascript
function clickHandler(event:MouseEvent):void {
	_oSendJavascript.addEvent(
		"AutoReloadIFrame();"
	);
}
 
//or…
 
// Omniture call
function clickHandler(event:MouseEvent):void {
	_oSendJavascript.addEvent(
		"var x = new Object(); x.pageName = 'Primary Section - Secondary Section';trackPageView(x);"
	);
}
 
//or…
 
// Google Analytics call
function clickHandler(event:MouseEvent):void {
	_oSendJavascript.addEvent(
		"_uacct = 'YOURGOOGLEACCOUNTNUMBER-000000-1'; urchinTracker();"
	);
}
 
// And of course you can stack calls
_oSendJavascript.addEvent("AutoReloadIFrame();");
_oSendJavascript.addEvent("function1();");
_oSendJavascript.addEvent("function2();");

The class:

package com.hydrotik.utils {
 
	/**
	 * @author Donovan Adams
	 * @version September 28, 2007
	 *
	 * @description SendJavascript Tracking Utility. Queues up SendJavascript events that fire off incrementally.
	 *
	 * @usage Example:
	 	<code>
			// This should only be called once! THe SendJavascript class is a Singleton pattern
			_oSendJavascript = SendJavascript.getInstance();
 
			// Called whenever an even needs to be triggered.
			function clickHandler(event:MouseEvent):void{
				_oSendJavascript.addEvent("AutoReloadIFrame();");
			}
		</code>
	 */
 
    import flash.events.Event;
    import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.net.navigateToURL;
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	import flash.system.Capabilities;
 
    public class SendJavascript {
 
		private static const DELAY:Number = .1; // Time in seconds
 
		private static var _oSendJavascript : SendJavascript;
 
		private static var _queueArray:Array;
 
		private static var _queueTimer:Timer;
 
		private static var _count:int;
 
		public static function getInstance() : SendJavascript{
			if (_oSendJavascript == null) _oSendJavascript = new SendJavascript();
			return _oSendJavascript;
		}
 
		public function SendJavascript():void {
			trace('\n\n\n\n======== SendJavascript Initializing '+(new Date()).toString()+'=========\n\n');
			_queueArray = [];
			_count = 0;
			_queueTimer = new Timer(DELAY*1000, 0);
			_queueTimer.addEventListener(TimerEvent.TIMER, sendEvent);
			_queueTimer.addEventListener(TimerEvent.TIMER_COMPLETE, queueComplete);
		}
 
		public function addEvent(p:String):void{
			trace("\t>> SendJavascript :: addEvent() - _count: "+_count);
			_queueArray.push("javascript: " + p);
			_queueTimer.repeatCount++;
			if(!_queueTimer.running) sendQueue();
			trace(_count);
			_count++;
		}
 
		private function sendQueue():void{
			trace("\t>> SendJavascript :: sendQueue()");
			_queueTimer.reset();
			_queueTimer.start();
		}
 
		private function sendEvent(event:TimerEvent):void{
			trace("\t>> SendJavascript :: sendEvent() - currentCount: "+_queueTimer.currentCount, _queueTimer.repeatCount);
			/* you can add any other variables you want to track above x.sprop2, x.channel, etc; */
 
			var playerType:String = Capabilities.playerType;
			if (playerType == "External" || playerType == "StandAlone") {
				trace("\t\tnavigateToURL("+_queueArray[_queueTimer.currentCount - 1]+"),'_self');");
			} else {
				navigateToURL(new URLRequest(_queueArray[_queueTimer.currentCount - 1]),'_self');
			}
 
		}
 
		private function queueComplete(event:TimerEvent):void {
			trace("\t>> SendJavascript - queueComplete() - type: "+event.type);
			flush();
           _queueTimer.reset();
 
        }
 
		private function flush():void{
			trace("\t>> SendJavascript :: flush()");
			_queueArray = [];
			_count = _queueTimer.repeatCount = 0;
		}
 
 
	}
 
}

Javascript Call Utility Source

The Discussion

see what everyone is saying

Respond

get in on the action.

* Required

bottega veneta deep coffee pocket bag deep weight loss pills bingo and game casino gambling online virtual how to win at slots versace deep coffee venus bag women does viagra work online bingo uk discount drugstore where to get viagra or cialis diazepam cheap without rx bingo and slots does cialis really work bingo gaming chanel yellow shoulder bag bingo for cash slot machine buy meds online without presciption lancel pearl premier flirt prada white shoulder bag prescriptions pain killers without a prescription viagra product information cialis generic levitra viagra cialis male enhancement online gambling offers manolo blahnik beige hangisi valium indications anya hindmarch beige hobo how does diazepam work who has the cheapest cialis price for tramadol levitra website price for generic viagra top anti depressants pharmacy zolpidem marc jacobs antique gold keylock messenger bag pill for acne casino gambling buy carisoprodol cheap create poker website zyban tablet jimmy choo purple wells shoes valtrex medication counseling for erectile dysfunction hey bingo louis vuitton patent beige sandals louis vuitton monogram idylle pink tote power bingo slot games gucci black evening bag xanax fedex oral jelly viagra new casino slots discount erectile dysfunction medication christian louboutin white ambrosina pumps poker machine games buy no phentermine prescription high stakes poker buy tory burch golden reva ballerina flats casino locations roulette casinos play online casinos bingo and slots viagra effect on women louis vuitton damier graphite keepall bandouliere marc jacobs royal blue keylock shoulder bag play roulette online casino mania online buy compazine buy gucci black trainers online casinos en internet how to win slots christian louboutin blush barcelona sandals prescription diet drugs us only mobile casino games natural clomid buy overseas viagra online casino canada online xanax fedex norvasc generic erectile dysfunction products zoloft canada uk viagra supplier casino bonus tory burch deep blue tory logo rain boots poker for money prescription drugs online adipex no prescription needed pharmacies geniune cialis no prescription ambien dosing how do muscle relaxants work valentino beige snakeskin clutch what is tadalafil ativan dosages sales viagra ysl white muse bag cialis to buy online gambling strategy cheapest phentermine pills christian dior biege medium saddle handbag alprazolam brand cheap viagra new zealand low cost adipex bally patent patent red jana tote ambien pharmacy manolo blahnik bow booties what is viagra used for dosage viagra new diet pill fda approved play slots online now cialis best price las vegas bingo cialis generic tabs versace purple venita bow satchel chloe patent purple cyndi tote fendi apricot snake peekaboo handbag discount lipitor prescription ambien ambien 10mg poker us levitra free samples do meridia phentermine work the same order celine black shoulder bag louis vuitton patent black sandals over the counter medication cheap 37 5 phentermine safe effective diet pills loewe white handbag dolce gabbana black trainers buying phentermine alprazolam generic for xanax ativan 2mg prada beige fairy l bag generic cialis canadian diet phentermine viagra online cheap europe cialis platinum play bingo levitra info prescription drugs migraines levitra alternative phentermine ingredient how does cialis work louis vuitton damier azure canvas galliera gm order amoxicillin new arthritis and psoriasis drug lipitor online pharmacy professional blackjack how does cialis ultram ingredients