HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunityDoc feedbackLog In
GitHubNuGetDev CommunityDoc feedback


You can track anything you like using Profile Store.

  1. Create FormsSubmission tracker class.

    
  2. 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.

    
  3. 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.

    
  4. 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.

    
  5. 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.

    
  6. 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.

    
  7. 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.

    
  8. 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.