GreenArrow Documentation

SimpleMH Click and Open Tracking

Overview

GreenArrow Engine offers click and open tracking when the SimpleMH method is used to inject mail. SimpleMH’s click and open tracking facility can be turned on or off on a per-Mail Class basis.

Click tracking rewrites links into a URL that GreenArrow Engine’s HTTP server listens on.

Open tracking inserts tracking images into HTML emails. If images are loaded by the recipient, an open gets registered.

If you’d like to receive notifications about click and open events, the Event Notification System can do this for you.

Click and open data is stored in two tables in GreenArrow Engine’s PostgreSQL database. The data in these tables should be treated as read-only. Here are the table structures:

clickthrough_clicks Table
Column Type Description
id integer Primary key for this table.
urlid integer Primary key of the clickthrough_urls entry this record corresponds to.
clicktime integer Time in seconds past the Unix epoch that the click occured.
emailaddress character varying Email address of the subscriber who clicked.
html_or_text character(1) h for an HTML email, or t for a text email.
email_code integer Value contained in the X-GreenArrow-Click-Tracking-ID header, if present.
email_code_text character varying Value contained in the X-GreenArrow-Click-Tracking-ID header, if present.
clickthrough_urls Table
Column Type Description   - - -
id integer Primary key for this table.        
sendid character varying(100) SendID of the message that was clicked or opened.        
listid character varying(100) ListID of the message that was clicked or opened.        
url text The original URL for links, or an empty string for opens.        

Dynamic Data

When dynamic data is being used, and you have control over how the URL is structured, it’s possible to reduce database bloat by putting dynamic data after a question mark. Database entries for URLs containing query strings are truncated at the question mark. The question mark, and query string following it are encoded in the re-written URL. For example, the following URL:

http://server.example.com?query=string&params=included

Would be stored in SimpleMH’s database as:

http://server.example.com

The re-written URL would look like:

http://greenarrow.example.com/click/e72/HZGVmYXVsdDEwMDAxLHQxLGh0dHA6Ly93d3cuZHJoLm5ldA/qP3F1ZXJ5PXN0cmluZyZwYXJhbXM9aW5jbHVkZWQ/scd6c91ef45

As a result, if a URL that’s inserted into a campaign is distinct for each subscriber, and contains subscriber-identification data following a question mark, SimpleMH is able to process this efficiently, and create only a single row in the clickthrough_urls table.

If a URL that’s inserted into a campaign is distinct for each subscriber, and contains subscriber-identification data that does not follow a question mark, then SimpleMH will insert a new row in the clickthrough_urls table for each user. This can lead to database bloat.

Example Query

Here’s an example query that displays opens for SendID a100525:

SELECT * FROM clickthrough_clicks WHERE id = (SELECT id FROM clickthrough_urls WHERE sendid = 'a100525' AND url = '');

The SendID is constructed by concatenating the InstanceID to the Mail Class. For example, if the following headers are present in a message:

X-GreenArrow-MailClass: a
X-GreenArrow-InstanceID: 100525

Then the resulting SendID would be a100525.

Using Port 80

It’s recommended that click and open tracking take place on port 80. If GreenArrow Engine’s Apache instance is on the same server as another Apache instance that is bound to port 80, one solution is to bind each Apache instance to a specific IP address. Instructions for doing with GreenArrow Engine’s HTTP server are in the HTTP Server Configuration Document.

Another solution is to use a PHP include on the non-GreenArrow Apache instance. To do this, create a PHP file with the following contents:

<?php
include '/var/hvmail/webapp/click/click.php';

After the PHP file has been created, update the $CLICKTHROUGH_URL variable in /var/hvmail/control/simplemh-config to point to the new PHP file’s URL:

$CLICKTHROUGH_URL = "http://greenarrow.example.com/click";

Send a test message after updating /var/hvmail/control/simplemh-config to verify that click and open tracking is still functioning.

If making this edit on a cPanel server, there may be additional security/permissions issues that make the PHP include an impractical solution. Another alternative to the PHP Include is to use a .htaccess redirect. Create or add to an existing .htaccess file in the docroot of the domain configured in /var/hvmail/control/simplemh-config with the following contents:

<Files .htaccess>
order allow,deny
deny from all
</Files>

Alias "/clicks" "/var/hvmail/webapp/click/click.php"
Alias "/opens" "/var/hvmail/webapp/click/click.php"

The configuration shown above requires that $CLICKTHROUGH_URL in /var/hvmail/control/simplemh-config ends in /click.php rather than simply /click.

If you encounter error after implementing the above, please do the following:

  1. Verify that PHP’s PostgreSQL database module has been installed. For example, if you’re using CentOS 6’s PHP 5.3 package, this module can be installed by installing the php53-pgsql package:

     yum install php53-pgsql
    

After making the above change, you may need to restart your web server.

Statefulness of Event Tracking

By default, SimpleMH uses an internal database for tracking recipient email addresses and link URLs. When a click, open, unsubscribe, bounce or spam complaint is received, the data is retrieved from that internal database. For most usages of GreenArrow, this default behavior is acceptable and fast.

SimpleMH can be configured to use stateless event tracking. This causes it to embed the email address and link URL data in emails instead of recording it in its database.

Stateless event tracking has two advantages:

  1. It allows you to offload event processing to another GreenArrow server.
  2. It reduces disk space requirements.

The downside of stateless event tracking is that it causes the average email size to increase since emails are used to store this extra information. For clicks, opens, and unsubscribes the information is embedded into the link. For bounces, the information is inserted into the email as an X-Mailer-Info-Extra header.

To turn on stateless event tracking, run:

echo 1 > /var/hvmail/control/opt.simplemh_stateless_event_handling

To turn it back off, run:

echo 0 > /var/hvmail/control/opt.simplemh_stateless_event_handling