Add a counter

A counter lets you track any action in a creative, for example, how many times a user clicked a button or moused over an object. There isn't a component for adding counters to creatives, so you need to use the API.

To record a counter:

Call this method:

enabler.counter(eventId:String, isCumulative:Boolean);

  • eventId is your counter's name in DoubleClick Studio. You can rename this in the Studio Web UI or in DFA/DCM to change what shows up in the final report.
  • isCumulative determines whether this counter can fire multiple times for a single user.
    • If this is set to false (the default), the counter tracks a maximum of one count per impression. This is called a capped counter.
    • If this is set to true, the counter tallies every time the counter is called. This is called an uncapped counter.

With this counter method, you can only input a string in the eventId. To use variables in the counter, see Use custom variables.

Try it!

  • Create a button in your creative, and name it myCounterBtn.
  • Make a counter named "My Counter" fire every time the user clicks the myCounterBtn object.

AS3 code snippet

var counterClickHandler:Function = function(event:MouseEvent):void {
    enabler.counter("My Counter");
}

myCounterBtn.addEventListener(MouseEvent.CLICK, counterClickHandler);

Test your work

Run the creative in Flash. When you click the counter, the following trace should appear in the output panel:

Enabler: Counter: My Counter