Counters

Build 1501 on 14/Nov/2017  This topic last edited on: 25/Oct/2016, at 11:54

Counters are used to maintain statistics about things like object access / views or user clicks etc. - so as the base for doing things like handling advertisement with impression count.

The command '.../do.ashx?cmd=objs' affects counters: it has a optional parameter 'counter', that specify the name of the counter to increment for each object returned by the command, so for example pointing a browser to:

http://...../do.ashx?cmd=objs&ids=XXXX&counter=GlobalImpressions

will display the XML of the object with id 'XXXX' and at the same time increment the counter GlobalImpressions associated with it.

See also the counters command of cmd4.

The 'counters' command of the do.ashx page with the same functionality (and parameters) of the cmd4 counters command, e.g:

http://myserver/gnportal/do.ashx?cmd=counters

will returns all the counter data etc.

The counter values are kept in the gn_CounterTable database table - they are not database attributes.

The counter values can be split by year, month, week, day, hour and total number. Which splits are used is specified by the 'intervals' attribute of the counter object.

Counters can be associated with objects (e.g. the number of impressions or view of a specific story) or global (e.g. total number of user logins) - depending on the value of the 'hasObject' attribute of the counter object.

Each counter increment can also be recorded in the audit trail - depending on the value of the 'audit' attribute of the counter object. The audit trail records allow to see exactly when the counter has been incremented and by which user.

Counter increments

Increments of object-specific counters generate IncCounter audit trail actions and include the object id and descriptive name.

Increments of global counters generate IncGlobalCounter audit trail actions.

The counter increment behavior of the '.../do.ashx?cmd=objs' command takes into consideration if the specified counter is a global one (i.e. not specific to an object): then it is incremented by the number of objects that the command is returning, not by just 1. So it is possible to increment a counter by an arbitrary amount in a single operation.

The IncCounter and IncGlobal counter audit trail entries have an additional 'N' attribute that specifies of how much the counter has been incremented. The default is 1 - so no 'N' attribute will be visible in an audit trail extraction for 'standard' counter increments by 1.

There is a 'Counters' optional property in the XML export options that specify a list of counter names. When objects are exported using cmd4 or srv4 using option with such property all the specified counters are incremented for each exported object. Global counters are incremented by the number of exported objects. Here is an example of an export options file specifying two counters to be incremented:

<!--

  Sample export options file - to be used in the 'cmd4 export' 

  and 'srv4 export' commands, '-opt' parameter

-->

<XmlExportOptions 

  xmlns="http://www.teradp.com/schemas/GN4/1/XmlExportOptions.xsd" 

  Encoding="UTF-8" 

  Indent="TwoSpaces" 

  NewLine="CRLF" 

  OmitXmlDeclaration="false" 

  DataAsId="false" 

  DataMaxSize="20000" 

  DataFiles="true" 

  AccessStrict="false" 

  OutputNulls="false" 

  RefKeys="true">

<Counters>

<Name>ImpressionsB</Name>

<Name>TotalImpressions</Name>

</Counters>

</XmlExportOptions>

There is a similar 'Counters' property in the feed configuration files, with the same use. See

Note that the counters will be incremented for the single publishing destination object the feed configuration is applied to - not for all the objects cointained in the publishing destination.

If the counters specified in the XML or feed options file do not export the export or feed generation fails with a 'NotFound' exception.

Counter commands

In do.ashx

command: IncCounter

this command is used for increment a counter (identified by name) optionally associated to one or more objects. After the increment the page return the counter data.

Parameters:

Ids: comma-separated database ids

Counter: Name of the counter to increment.

IncCounterSize: Value to increment the Counter (Min value: 1, Default value: 1)

Examples

/do.ashx?cmd=inccounter&ids=235,613&counter=GlobalImpressions

Non-global counter GlobalImpressions is incremented by once for the associate objects with id 235, 613

/do.ashx?cmd=inccounter&ids=235,613&counter=Test&IncCounterSize=3

Non-global counter GlobalImpressions is incremented by three for the associate objects with id 235, 613

/do.ashx?cmd=inccounter&counter=Test&IncCounterSize=3

Global counter Test is incremented by three, no objects associated

/do.ashx?cmd=inccounter&counter=GlobalImpressions

Non-global counter GlobalImpressions isn’t incremented. In this case is required one or more ids.

After the increment in the page is visualized the counter data, the results are similar to the results of command counters. For this reason, there are other three options for view the counter result:

Interval: Time interval to use.

From: Start time and date

To: End time and date

The default values are set for view all counters, but if the command line is:

/do.ashx?cmd=inccounter&ids=235&counter=GlobalImpressions&IncCounterSize=3&Interval=HourVal

 &from=2008-01-01T00:00:00Z&to=2009-06-01T00:00:00Z

GlobalImpressions counter is incremented by three for the object 235, but the view result select only the counter in the interval.

do.ashx option: counter in the command objsNav

With this option there is a counter increment for every object returned. It is similar to the counter option in the objs command

IN CMD4

See inccounter

See also

http://forum.teradp.com/topic.asp?TOPIC_ID=240&SearchTerms=counters