You can track anything you like using Profile Store.
Create FormsSubmission tracker class.
Add necessary dependencies.
There are the following dependencies to three classes:
ITrackingService. Will be used to send the tracking data.
ISiteDefinitionResolver. Will be used to get SiteId.
Create a method for tracking forms submission.
Create an async method for sending page view tracking events to be async all the way.
The method has two dependencies:
IContent. The forms content that is being tracked.
HttpContextBase. Is needed in the Track method of ITrackingService.
Create model classes for tracking forms submission.
Track the following of the submitted forms:
Name. The name of the form.
ContentGuid. The id of the form.
SiteId. The site this form belongs to.
Create instance of model in the Track method.
Use SiteDefinitionResolver to get the site for the content. Then create an instance of the class just created.
Create a method for getting UserData.
Obtain the name and email of the user, if possible. This example uses **EPiServer.Security.PrincipalInfo** for the name and **EPiServer.Personalization.EPiServerProfile** for the email.
Create TrackingData instance.
Create an instance of trackingData, where the generic type is our tracking model. Then set the properties:
EventType. Schema name for the tracking event.
User. UserData created in the CreateUserData method.
Value. A human readable text about the event that will be created.
Payload. An instance of the generic type, containing all properties with values needed for the specific event.
Send tracking data.
The last thing to do is call the tracking service with the trackingData, and HttpContextBase.
## FormsSubmissionTracker class summary
Here is a summary of the whole class:
## Use FormsSubmissionTracker class
You can now take a dependency to FormsSubmissionTracker when a forms is being submitted, and call the Track method in this class.