Rule Engine - Visitor Traffic & Analytic Rules


An analytic rule is a defined series of actions based on conditions. If the conditions evaluate as successful/true, actions for reporting, redirecting or blocking are applied.

Visitor Traffic and Analytic Rules is a powerful feature through which you can:

  • Classify and group your traffic based on rules you define, giving you customized visitor data and analytic reports
  • Log Search Engines that are not already specified
  • Create customized spider rules for reporting spider visits, redirecting spiders when necessary and managing bandwidth usage and costs arising from spider traffic 
  • Mark visitor sessions as suspect for reporting
  • Redirect page requests
  • Block Requests from fraudulent visitors and manage bandwidth usage and costs

Types of Rules: Admin Rules and User Rules

Admin Rules are created by Spark Pay online stores to setup commonly used rules for anlytics and reporting such as classifying visitor data from known Search Engines, Spiders and Feeds. User Rules are rules created by storeowners and are site specific. They are run after Admin Rules and hence can override Admin Rules.

Things such as handling ad code commissions or logging spiders still happens as usual after the rules have run.  The outcome of the rules can effect some of this, depending on what data gets written to the session.

Components of a Rule: Conditions and Actions 


The following conditions can be used: 

  • Ad Code – Checks the incoming AdCode against a defined value to see if it matches.  Can be set to * to match any value.
  • Affiliate Code – Checks the incoming Affiliate Code against a defined value to see if it matches.  Can be set to * to match any value.
  • Blank Source – Checks to see if the source is blank.  This can be used at the end of a set of rules to set a default or undefined source.
  • IP Address – Checks against the IP address on the session, adheres to wildcard matching (i.e. 192.168.*.* or 10.*.1.*, etc.)
  • Pay Per Click Keywords – Checks the incoming Pay Per Click keywords for a defined value, or if set to * matches any value.  Can restrict this to be from a certain origin as well (default is Any, currently supported are Google, Yahoo, and MSN).
  • Query String – Checks the query string of the request for variables such as feed=, and can match against a defined value.  * matches any value. Includes a flag for exact match.
  • Referring Domain – Checks for a defined mask against the referring domain, includes a flag for exact match. (i.e. “.google.”).
  • Search Phrase – Checks the search phrase on the referrer for a defined value.  * matches any value.  The query variable that contains the search string must be specified.  Includes a flag for exact match.
  • Store – Checks to see if the session belongs to a specified store. This is supported for multiple store. Microstore are not supported as yet.
  • User Agent – Checks the user agent, which is the identifier for the browser/program accessing your site, for a specified value, includes a flag for exact match.

The conditions can be evaluated on an ANY or ALL basis.  An ANY will pass if any 1 of the conditions are matched and will perform the actions set.  An ALL match requires ALL conditions to match before running the action.


Each rule can contain one or more of those conditions. Depending on the conditions set, if the rule is successful, then all of the actions set on the rule will apply. 

The following Actions can be applied:

  • Log Search Engine – Logs the visit as coming from a search engine, along with the engine’s name and search query.
  • Mark Suspect – Marks the session as suspect.
  • Set Source – Sets the source to the specified text value.
  • Set Source Group – Sets Source Group, to the specified text value.  This is a grouped field used to group multiple sources that have a common more general source (such as “Google" being the source would have "Search Engine" as the Source Group, or Shopzilla would have the "Comparison Engine" group).  This allows you to see your primary sales channels on reports.
  • Set Spider – Flags the session as a spider, when a session is flagged as a spider no session is stored, only the bare identifying information to save valuable SQL storage processing and space.  Additionally, a spider cannot check out or log in to your site protecting your data.

Rules are loaded when a session starts and currently cached for 5 minutes, or until the rules are next updated via the admin console.

How To Setup Rules:

Browse to Tools > Power Features > Rule Engine > Visitor Traffic & Analytics.

Select User Rules, you can edit an existing, or create a new one from here.

Define the Rule:

  1. Name the Rule
  2. Define Conditions and use the '+' symbol to add conditions. You can add multiple conditions and set for the rule to be successful if any or all conditions are met.
  3. Define Actions and use the '+' symbol to add actions. You can add multiple actions to be run when condition/s are met.
  4. Save

Note: By Default Rules are sorted alphabetically and run and apply in the exact order that they are listed. Since rules override each other, the last rule overrides any previous rules. If you have a condition that evaluates as true for two separate rules and the Action is the same field (example setting a Source or Source Group), the last rule overrides any other preceeding it. You can use the Sort Order to define which rule should apply. 



Check out these other articles on the Rule Engine:

Rule Engine - Visitor Traffic & Analytic Rules

Rule Engine - Customer Event Rules

Rule Engine - Order Event Rules

Have more questions? Submit a request


  • Avatar
    Walter Landman

    What is the lifetime of this marking?  Suppose I visit the site today from a search engine.  I close my browser and come back in two weeks.  Will my 2nd visit still be considered as coming from a search engine or will it be considered direct?  

  • Avatar
    Brandon Young

    Any more information on the question above would be greatly appreciated!

  • Avatar
    Austin Smith

    Thanks for the question, Walter.

    The referring domain is session based. In other words, the 2nd visit will have the same referrer as the initial visit if the session is the same; if the 2nd visit is a different session, than the referring domain could be different. The server-side lifetime of visitor sessions is by default 12 months, but this can be changed in Settings > Security > Data Retention. Keep in mind a new session will be created if the customer uses a different device, different browser, etc.

    Hope that answers your question.

    --Online Store Support

  • Avatar
    Brandon Young

    So I'm working on Analytical rule 260 [ppc] Google Adwords and I want to change it so that I can see what keyword was clicked on. In my AdWords account I have set up a custom parameter in the URL to be keyword={keyword} which puts the keyword in the URL. How can I set up a rule to set the ppc keyword to this value? Or would it just be easier for me to write a custom script?

  • Avatar
    Austin Smith


    You can set the session's PPC keyword with an analytic rule action (as you've probably noticed), but I'm not sure there's a way to pull in the the value of a specific query string from the URL (like your keyword parameter).

    There is a merge code that you can try: ##QUERYSTRING[name]##- Displays the value from the query string and puts it in place of this merge code. For example, you would paste this into the `Set PPC Keyword` action: ##QUERYSTRING[keyword]##.

    If that doesn't work, you'll need a custom script.

    Hope that helps!

    SPOS Support

  • Avatar
    Brandon Young


    Thanks I'll give it a try and see if it works. I'll post back here if it works so everyone else can see.

  • Avatar
    Brandon Young

    I implemented an analytical rule that takes the incoming URL and searches to see if "/?src==ppc" 'is contained within. Then I created a condition that Set PPC Keyword' as ##QUERYSTRING[keyword]## and although it recognized the URL correctly it doesn't recognize the merge code as a value and just puts ##QUERYSTRING[keyword]## where the keyword should be.

    So my new question is if I wanted to set the sessions ppc keyword with an analytical rule like normal do I have to create do I have to create a rule for each ppc keyword that I have in AdWords in order to get them to show up? Although i could do this I really don't want to since we have a lot of keywords and if I change them I would have to update it in two places.

    Also, I was looking at writing a script for accomplishing this, but I can't seem to find a way to set the ppc keyword using the Spark Pay api. Do you know if this is possible?