Action log

The action log tracks actions performed by a user when interacting with the site. The system can track basically anything. Our solution ships with a range of actions that can be enabled and tracked. You can also write your own custom actions that can utilize the same system.

Enabling actions

By default, none of the actions in an installation (built-in and custom) are enabled. You must enable those actions you want to use in the Settings dialogue in the System module:

actions

The reason you have to choose which actions to enable is because tracking all the actions all the time might result in huge amounts of data in the system. If you're not using all that data, there is no point in storing it. We recommend that you only enable those actions you think are needed in the site. Additional action can be enabled at a later date, but be aware that you only get data from the moment you enable an action.

Built-in actions

  • BlogCommentPostAction
  • CompletedFunnelAction
  • FormSubmitAction
  • ForumMessagePostedAction
  • ForumThreadCreatedAction
  • InternalSearchAction
  • LoginAction
  • NewsletterLinkClickAction
  • NewsletterReadAction
  • NewsletterSubscribeAction
  • NewsletterUnsubscribeAction
  • PageViewAction
  • ProductAddedToCartAction
  • ShoppingCartOrderedAction
  • UserRegistrationAction

Create custom actions

Relatude ships with the actions you see listed above. If you need additional actions, the Action log in Relatude has full support for creating custom actions. 

The first step is to create a new class that inherits from ActionEvent. The bare minimum you have to do is to call the base constructor. This is the LoginAction:

public class LoginAction : ActionEvent {
        public LoginAction(WAFSession session) : base(session) { 
        
        }
    }

By default, the following data is logged when an action occurs:

  • UserId
  • SessionId
  • VisitorId
  • ActionClass
  • EventDate
  • NodeId
  • LCID
  • VisitorOS
  • SiteId
  • Segments
  • Year
  • Month
  • Day
  • Hour
  • WeekNumber
  • Country
  • City

 

If you need to log additional data about the action, you can add additional properties to the class, set an attribute and override a method. This is another example:

 [CustomActionProperty("FormId", ActionPropertyDataType.IntegerType)]
    public class FormSubmitAction : ActionEvent {
        public int FormId {
            get;
            set;
        }

        public FormSubmitAction(WAFSession session) : base(session) { 
        
        }

        public override Dictionary<string, IActionParameter> GetActionParameters() {
            Dictionary<string, IActionParameter> parameters = new Dictionary<string, IActionParameter>();
            parameters.Add("FormId", new IntegerActionParameter() { Value = FormId });
            return parameters;
        }
    }

Logging an action

After you have created the action, you need to tell the system when that action occur. To give you an example, for the FormSubmitAction shown above, the code to log a form submit is added to the OnSubmit method on the WebForm content class:

public virtual void OnSubmit(WebFormSubmit submit) {
            try {
                if (ActionEventManager.IsActionEventClassActivated<FormSubmitAction>()) {
                    FormSubmitAction action = ActionEventManager.CreateAction<FormSubmitAction>(this.Session);
                    action.FormId = this.NodeId;
                    ActionEventManager.AddToQueue(action);
                }
            } catch (Exception ex) {
                WAFLog.Insert("ActionEvent", ex);
            }
        }

Deleting old action log data

The action log can quickly grow very fast, and to keep the data size manageable, we recommend that you delete old action log data regularly. This is best done in the system module, where you have an option on the Indexes menu called "":

delete_actions

This opens a dialogue where you can choose the date you want to delete actions older than, and if you want to delete all action types or just one type:

actions_dialogue1

If no action type is specified, it will delete all actions older than the date set.