Referrer Module Tags

ExpressionEngine will track referrers with the Referrer Module. A "referrer" is the URL or website that led a user to get to your site. For instance, let's say a user performed a Google search and saw your site in the results. She then followed the result link and visited your page. Because Google was the site that sent her to your page, google.com would be the "referrer". Essentially, tracking referrers allows you to easily see how people are finding your website and from where they are coming.

To view the referrers use the following tag within a table such as this:

<table border="0" width="100%" cellpadding="6" cellspacing="1">
<tr>
<th>Date</th>
<th>From</th>
<th>IP Address</th>
<th>To</th>
</tr>

{exp:referrer limit="50" popup="yes"}
<tr>
<td>{ref_date format="%m/%d/%Y"}</td>
<td>{ref_from}</td>
<td>{ref_ip}</td>
<td>{ref_to}</td>
</tr>
{/exp:referrer}

</table>

Note: You enclose from the opening <tr> to the closing </tr> since that is the portion that gets repeated.

Blacklisting

ExpressionEngine maintains an editable "blacklist" so that you can keep certain IP addresses, URLs, or even User Agents from being counted in your referrals. You may access this list through the Referrer section of the Modules area.

This blacklist is useful for blocking unwanted sites from appearing in your referral list. Each blacklist entry should simply be placed on its own line within the appropriate area.

Parameters

limit=

limit="50"

The number of results you want to see

popup=

popup="yes"

This parameter makes the link to the referring site open in a new window.

Variables

ref_agent

{ref_agent}

The user agent that made the referral to the site. For most cases, the "user agent" is simply a web browser that visited your site. The {ref_agent} variable outputs the full user agent string recorded by ExpressionEngine. It might look something like:

Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)

Which is the common user agent string for Internet Explorer 5.5 running on a Windows 2000 machine.

ref_agent_short

{ref_agent_short}

A shortened version of the user agent that made the referral to the site.It might look something like:

Mozilla/5.0

ref_date

{ref_date format="%m/%d/%Y"}

The date on which the referral was made.

ref_from

{ref_from}

The URL of the referring site.

ref_ip

{ref_ip}

The IP address of the referring site.

ref_to

{ref_to}

The URL of the page to which they arrived.

switch=

{switch="option_one|option_two}

This variable permits you to alternate between any two values as the entries are displayed. The first entry will use "option_one", the second will use "option_two", the third "option_one", and so on.

The most straightforward use for this would be to alternate colors. It could be used like so:

{exp:referrer limit="50" popup="yes"}
<tr class="{switch="one|two"}">
<td><div>{ref_from}</div></td>
<td><div>{ref_to}</div></td>
</tr>
{/exp:referrer}

The entries would then alternate between <tr class="one"> and <tr class="two">.

Multiple instances of the {switch=} tag may be used and the system will intelligently keep track of each one.