How it is done
I have made a Silverlight class library called Quebec.Silverlight.Behaviors containing one class called AnalyticsAction. The class derives from TargetedTriggerAction making it possible to set a Trigger and a Target to the Behavior.
Finally I implemented the Invoke method. This methods is called when the target is triggered (e.g. Click on Button, MouseEnter on Rectangle). The Invoke method is overridden from the base class.
This Behavior can easily be extended with several properties and integrate into other tracking engines.
How to use the AnalyticsAction in Expression Blend
To use the AnalyticsAction behavior open your project in Expression Blend and add a reference to the assembly Quebec.Silverlight.Behaviors.dll.
Locate the control that you wish to add tracking to – select the control from the object browser. Remember that you can select both the LayoutRoot and controls added to the LayoutRoot.
Go to the Assets Library and select the Behavior tab. DoubleClick the AnalyticsAction to add it to your selected control.
You are now ready to track events directly to Webtrends using Expression Blend.
How to use AnalyticsAction in Visual Studio (XAML)
To use the AnalyticsAction behavior open your project in Visual Studio and add a reference to the assembly Quebec.Silverlight.Behaviors.dll.
Locate the XAML page/control that you wish to add tracking to. Add a namespace reference to the System.Windows.Interactivity assembly and the Quebec.Silverlight.Behaviors assembly.
Locate the control that you wish to add tracking to in your XAML page. Add a Trigger using the attached properties Interaction.Triggers and add an EventTrigger to the Trigger. At the EventTrigger it is possible to specify the EventName that triggers the tracking.
You are now ready to track events directly to Webtrends using Visual Studio.