FintezaAnalytics.AspNet 1.0.2

Finteza SDK is a set of ready-made scripts for sending and proxying events from the server side of ASP.NET websites.

Install-Package FintezaAnalytics.AspNet -Version 1.0.2
dotnet add package FintezaAnalytics.AspNet --version 1.0.2
<PackageReference Include="FintezaAnalytics.AspNet" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FintezaAnalytics.AspNet --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Using

using FintezaAnalytics;
...
// call the SDK methods

Initialization

The SDK is initialized in the global application class in the Global.asax file. Call the Finteza.RegisterAnalytics method inside the Application_Start method of the application:

Finteza.RegisterAnalytics(websiteId: "{WEBSITE_ID}");

Specify the following parameters:

  • websiteId * - Website ID. It can be obtained in the website settings (ID field) of the Finteza panel.
  • url - Finteza server address. In most cases, it should not be changed.
  • logger - Microsoft.Extensions.Logging.ILogger interface implementation.

After that, add the following call in the Application_End method of the application:

Finteza.UnregisterAnalytics();

It releases the resources used by Finteza SDK.

Proxying requests

To enable proxying, set its parameters in addition to the main parameters in the Finteza.RegisterAnalytics initialization method:

Finteza.RegisterAnalytics(websiteId: "{WEBSITE_ID}", token: "{TOKEN}", path: "{PATH}");
  • token * - Token for signing the X-Forwarded-For header. You can get this value in the website settings of the Finteza panel: open the Counter section, enable the "Proxying the script and requests" option and copy the value from the "Proxy token" field.
  • path - Beginning of the path for requests to be proxied. If the parameter is not specified, the default /fz value will be used.

Then, add the following line in the Web.config file, under the system.webServer/modules section:

<add name="FintezaAnalyticsProxyModule" type="FintezaAnalytics.ProxyModule" />

Sending events

Call the Finteza.Tracker.SendEvent method:

Finteza.Tracker.SendEvent(name: "{EVENT}", referer: "REFERER");

Using this method, you can register the events and pass additional information as parameters, for example, a type of a purchased good, price, currency, etc. The following parameters are supported:

  • name * - Event name. The maximum length is 128 symbols.
  • referer - The address of the page from which the event is sent.
  • backReferer - The address of a web page a visitor was located at before performing a tracked action.
  • userIp - The IP address of the visitor who performed a tracked action.
  • userAgent - The user-agent of the visitor who performed a tracked action.
  • unit - Parameter measurement units, for example, USD, items, etc. The maximum length is 32 characters.
  • value - The value of the parameter. The maximum length is 64 symbols.

There is no need to specify the referer parameter each time the event is sent, if you set its default value during initialization. During Finteza.RegisterAnalytics call, specify the additional parameter defaultReferer:

Finteza.RegisterAnalytics(websiteId: "{WEBSITE_ID}", defaultReferer: "{DEFAULT_REFERER}");

If you do not use defaultReferer, specify referer during each SendEvent call. Otherwise, the events will not be sent.

Another variant is available for the Finteza.Tracker.SendEvent function:

Finteza.Tracker.SendEvent({CONTEXT}, "{EVENT}");

Instead of the explicit specification of referer, backReferer, userIp, userAgent, here the request execution context is specified, from which the specified parameters will be received and sent to Finteza.

  • httpContext * - Current HTTP request execution context, from which parameters referer, backReferer, userIp and userAgent are automatically formed.
  • name * - Event name. The maximum length is 128 symbols.
  • unit - Parameter measurement units, for example, USD, items, etc. The maximum length is 32 characters.
  • value - The value of the parameter. The maximum length is 64 symbols.


* - required parameters

Using

using FintezaAnalytics;
...
// call the SDK methods

Initialization

The SDK is initialized in the global application class in the Global.asax file. Call the Finteza.RegisterAnalytics method inside the Application_Start method of the application:

Finteza.RegisterAnalytics(websiteId: "{WEBSITE_ID}");

Specify the following parameters:

  • websiteId * - Website ID. It can be obtained in the website settings (ID field) of the Finteza panel.
  • url - Finteza server address. In most cases, it should not be changed.
  • logger - Microsoft.Extensions.Logging.ILogger interface implementation.

After that, add the following call in the Application_End method of the application:

Finteza.UnregisterAnalytics();

It releases the resources used by Finteza SDK.

Proxying requests

To enable proxying, set its parameters in addition to the main parameters in the Finteza.RegisterAnalytics initialization method:

Finteza.RegisterAnalytics(websiteId: "{WEBSITE_ID}", token: "{TOKEN}", path: "{PATH}");
  • token * - Token for signing the X-Forwarded-For header. You can get this value in the website settings of the Finteza panel: open the Counter section, enable the "Proxying the script and requests" option and copy the value from the "Proxy token" field.
  • path - Beginning of the path for requests to be proxied. If the parameter is not specified, the default /fz value will be used.

Then, add the following line in the Web.config file, under the system.webServer/modules section:

<add name="FintezaAnalyticsProxyModule" type="FintezaAnalytics.ProxyModule" />

Sending events

Call the Finteza.Tracker.SendEvent method:

Finteza.Tracker.SendEvent(name: "{EVENT}", referer: "REFERER");

Using this method, you can register the events and pass additional information as parameters, for example, a type of a purchased good, price, currency, etc. The following parameters are supported:

  • name * - Event name. The maximum length is 128 symbols.
  • referer - The address of the page from which the event is sent.
  • backReferer - The address of a web page a visitor was located at before performing a tracked action.
  • userIp - The IP address of the visitor who performed a tracked action.
  • userAgent - The user-agent of the visitor who performed a tracked action.
  • unit - Parameter measurement units, for example, USD, items, etc. The maximum length is 32 characters.
  • value - The value of the parameter. The maximum length is 64 symbols.

There is no need to specify the referer parameter each time the event is sent, if you set its default value during initialization. During Finteza.RegisterAnalytics call, specify the additional parameter defaultReferer:

Finteza.RegisterAnalytics(websiteId: "{WEBSITE_ID}", defaultReferer: "{DEFAULT_REFERER}");

If you do not use defaultReferer, specify referer during each SendEvent call. Otherwise, the events will not be sent.

Another variant is available for the Finteza.Tracker.SendEvent function:

Finteza.Tracker.SendEvent({CONTEXT}, "{EVENT}");

Instead of the explicit specification of referer, backReferer, userIp, userAgent, here the request execution context is specified, from which the specified parameters will be received and sent to Finteza.

  • httpContext * - Current HTTP request execution context, from which parameters referer, backReferer, userIp and userAgent are automatically formed.
  • name * - Event name. The maximum length is 128 symbols.
  • unit - Parameter measurement units, for example, USD, items, etc. The maximum length is 32 characters.
  • value - The value of the parameter. The maximum length is 64 symbols.


* - required parameters

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.2 14 2/13/2020
1.0.1 51 1/23/2020
1.0.0 65 1/21/2020