Lasting Impressions for EECMS v2

Lasting Impressions Pro ExpressionEngine Plugin

Compatibility

Compatible with EE versions2.5.2+
Lasting Impressions Version3.0.2

Overview

This ExpressionEngine module will record the entries viewed by each visitor to your site. You can then re-display each visitor's entries to them using all the same functionality as the standard ExpressionEngine channel:entries tag pair.

This module was originally designed for ecommerce sites to display a "recently viewed products" list to each customer, however it can be used anywhere you need to record and "playback" entries seen by each visitor to your site.

You can track entries from any or all channels and then specify which channel you are interested in when playing them back.

The entries are stored in a cookie for each visitor to your site.

With Version 3 you can now keep logs of the number of views of each tracked entry and delve into your stats and view reports (see reports documentation) on tracked Channel Entries.

Usage

The module consists of three template tags:

{exp:lasting_impressions_pro:register}
This is used to register the id of each entry you want to record.

{exp:lasting_impressions_pro:entries} {/exp:lasting_impressions_pro:entries}
This tag pair which is used to re-play the channel entries of each of the ids previously recorded by the register tag.

{exp:lasting_impressions_pro:form}{/exp:lasting_impressions_pro:form}
This tag is used when you want your visitors to be able to remove items from their "recently viewed" list. See Allowing a visitor to remove items from the list of recently viewed entries.

Installation

  1. Unzip the Lasting Impressions Pro zip archive
  2. Upload the folder /ExpressionEngine/system/third_party/lasting_impressions_pro to your site's ExpressionEngine system/third_party folder
  3. Upload the /themes/third_party/lasting_impressions_pro folder to your themes/third_party folder.
  4. Log in to the ExpressionEngine CP and navigate to Add-Ons -> Modules
  5. Locate Lasting Impressions Pro in the list and install it by selecting the "Install" link in the Action column. Make sure you install both the Extension and the Module.

Control Panel

Module Settings

Add-ons -> Modules -> Lasting Impressions Pro

Lasting Impressions EE Control Panel Module Settings

Before you can enter or edit the settings you just make sure that the plug-in is enabled by selecting the "enable" radio button.

Maximum number of entries to record: specify the maximum number of entries which will be recorded for each visitor. Newer entries will push older ones off the list.

Number of days before cookie expires: the entries that a visitor has seen are stored in a cookie. That cookie will exist for the number of days specified here or until the visitor clears their cookies.

Extension Settings

Add-ons -> Extensions -> Lasting Impressions Pro -> settings

Lasting Impressions EE CP Extension Settings

Lasting Impressions also has an ExpressionEngine Extension which is used to replace tags in the EE channel entries loop. One of it's functions is to format the date and time of the {lasting_impressions:last_view} variable. If you find that the date and time are incorrect then this may be due either to your server's time being wrong or a problem with EE's localisation function. You can control whether Lasting ImpressionsPro uses EE's localisation by navigating to Add Ons -> Extentions -> Lasting Impressions and switching localisation on or off.

Template Tags

Register

The first thing you'll need to do is register the entries that your visitors are visiting. To do this, add the following tag inside a channel:entries tag pair to track the ids of the displayed entries.

{exp:lasting_impressions_pro:register entry_id="{entry_id}"}

Parameters

  • entry_id
  • make_revisits_most_recent
  • enable_reporting

entry_id

entry_id="123" or
entry_id="{entry_id}"

[Required] You must supply an entry ID, one id at a time. The id can be hard coded or passed in from an enclosing channel entries tag pair.

make_revisits_most_recent

make_revisits_most_recent="yes|no"

Default: "yes"

[Optional] Ensures that on subsequent visits to an entry which has already been recorded, that entry is moved to be the most recent entry in the list. Set this to "no" to keep entries in their original position in the list. You can still output the entries by most recent by setting the display_order parameter of the entries tag to "recent".

enable_reporting

enable_reporting="yes|no"

Default: "no"

[Optional] Set this parameter to "yes" and Lasting Impressions will record every channel entry visited. You can then report on these visits by using the reporting screen (see below). NB: On a busy site the database could fill up quite quickly with data so we recommend regularly exporting the data and then purging.

Entries

N.B. As the Entries tag pair inherits from the Channel Entries tag pair you need to observe the same rules with regard to nesting.  Do not nest the {exp:lasting_impressions_pro:entries} tag pair inside an {exp:channel_entries} tag pair (use an embed or another method if you need the Lasting impressions entries tag to be placed within an ExpressionEngine Channel Entries tag pair).

Add the following tag pair to a template to display the list of recently viewed items:

{exp:lasting_impressions_pro:entries}
... your custom fields and markup go here ...
{/exp:lasting_impressions_pro:entries}

This tag pair is identical to the ExpressionEngine channel entries tag pair. The parameters are limited to those listed below however you can use any of the variables / custom fields that you would normally use in your channel entries loop.

Parameters

  • channel
  • display_order
  • status 

channel

channel="shop_products"

[Required] You must specify which channel you require for your results. Without this you will get errors if you choose channel fields that are not global.

display_order

display_order="recent|register"

[Optional] Display the entries by the most recent first (as determined by their time stamp) or the order in which they were registered. Useful when the registered order isn't necessarily in date/time order when make_revisits_most_recent is set to "no". Setting this value to "recent" will ensure a list of entries displayed in the order they were last visited.

status

status="open|latest"

[Optional] Specify the ExpressionEngine channel status of the channel entries you wish to display  The Default is "open". Multiple values are separated by a pipe character.

Variables

Choose any channel field name used by the entries. The returned entries work just like they do in the standard ExpressionEngine channel entries tag.

You can also use the Lasting Impressions Utility Tags view_count and last_view tags within this tag pair

Utility Tags

You might want to know if the visitor has any lasting impressions in their cookies.  This is useful for testing if there are any lasting impressions to display.  You can call this as a single tag outside of the lasting_impressions tag pair.

{exp:lasting_impressions_pro:count}

There are also two additional tags which can be used both in the entries tag and in the forms tags, and as a bonus you can use them within a standard ExpressionEngine channel entries tag pair as well.

  • view_count
  • last_view

view_count

{lasting_impressions_pro:view_count}

The number of times an entry has been viewed

last_view

{lasting_impressions_pro:last_view format="[date_format]"}

The date and time of the last time each entry was viewed. You can use all the usual date formatting parameters on this variable.

If you want to use these two variables within a standard channel entries tag then it is best to wrap them in an {if} statement something like this example:

{if "{lasting_impressions_pro:view_count}" > 0}

   Viewed {lasting_impressions_pro:view_count} times

   Last viewed on {lasting_impressions_pro:last_view format="%D, %F %d, %Y - %g:%i:%s"}

{/if}

Form

Enabling a visitor to remove items from the list of recently viewed entries

Lasting Impressions Pro gives you two methods to choose from which enable visitors to remove items from their list of recently viewed entries.  You can wrap each item in a form, submit data and refresh to get the new list or you can use Ajax which will reload the data on the fly.

Posting a form to Remove Entries

Each entry will be wrapped in a form and a visitor will be able to click on a link or a button to remove entries. You can display each entry within this tag in exactly the same way as you would use an ExpressionEngine channel entries tag pair. All the fields are available to you along with the two additional fields described above.

{exp:lasting_impressions_pro:form}
    ... your custom fields and markup go here ...
{exp:lasting_impressions_pro:form}

Parameters

  • channel
  • display_order
  • status
  • submit_value
  • use_html5
  • use_ajax
  • listings_template
  • parent_tag_id

channel

channel="shop_products"

[Required] You must specify which channel you require for your results. Without this you will get errors if you choose channel fields that are not global.

display_order

display_order="recent|register"

[Optional] Display the entries by the most recent first (as determined by their time stamp) or the order in which they were registered. Useful when the registered order isn't necessarily in date/time order when make_revisits_most_recent is set to "no". Setting this value to "recent" will ensure a list of entries displayed in the order they were last visited.

status

status="open|latest"

[Optional] Specify the ExpressionEngine channel status of the channel entries you wish to display  The Default is "open". Multiple values are separated by a pipe character.

submit_value

submit_value="Remove ..."

[Optional] The tag pair will generate either a submit button or an anchor for you to use as the remove link. This is especially useful for the ajax option (below) as it will ensure that each button or link contains the correct css class used by the built in JavaScript. To ensure the tag pair inserts a button or link you use a {submit_button} or {submit_link} variable.

This parameter lets you specify what text should be displayed in the resulting markup. If you include either of the submit tags but omit this parameter then the default text "Remove ..." will be used. Of course you're free to use your own link or button.

use_html5

use_html5="yes|no"

[Optional] If the tag pair is generating a submit button for you, should the resulting markup close the tag with a > (html5) or with a />

use_ajax

use_ajax="yes|no"

[Optional] You can submit the form using AJAX by setting this parameter to "yes". If you do this then you must include the supplied AJAX script by using the {exp:lasting_impressions:load_js} tag (see below) and you must also specify the listings_template and parent_tag_id paramters as well.

listings_template

listing_template="template_name"

[Required if use_ajax="yes"] This tells the ajax call which template to use for re-listing the entries once one of them has been removed. See Using Ajax for more information

parent_tag_id

parent_tag_id="parent_tag_id"

[Optional] This tells the AJAX function which containing tag to use for displaying the revising listing. See Using Ajax for more information

Variables

Use any channel field name used by the entries. The returned entries work just like they do in the standard ExpressionEngine channel entries tag.

You can also use the Lasting Impressions Utility Tags view_count and last_view tags within this tag pair

The tag pair will also generate a submit button or link for you, which ensures the correct class parameter is used if you want to use the AJAX functionality. These variables are 

{submit_button} 

which will generate an HTML submit button, and

{submit_link}

which will generate an HTML anchor tag.

Both will include the css class remove-lasting-impressions which the AJAX JavaScript uses to attach its "click" event to.

Using Ajax

You can avoid refreshing the whole page, here's how.

Lasting Impressions Pro comes with some JavaScript that you are free to use.  You must load the JavaScript using this tag anywhere on your page:

{exp:lasting_impressions_pro:load_js}

Parameters

load_jquery

load_jquery="true|false"

Default: "true"

Lasting Impressions Pro comes with version 1.10.2 minimized version of JQuery.  If you are already loading JQuery, set this parameter to false to avoid loading conflicting JQuery files however, if you do this then make sure you insert this tag AFTER you load JQuery.

When displaying the list of recently viewed items you will use the form tag (as mentioned earlier) making sure you include the three additional AJAX specific parameters - use_ajax, listings_template and parent_tag_id.

Your listings template should be simply the lasting_impressions:form tag (as specified above) which you use to list out all the recorded entries. If you include this in your main page as an {embed} within a containing element the AJAX call will re-load the template and insert it into that containing element each time an entry is removed.

You tell the AJAX where the containing element is by giving it an id and then entering that id into the parent_tag_id parameter

The listings_template tag must include the fully qualified path to the template as you would use in a standard ExpressionEngine {embed} tag like this:

listing_template="includes/lasting_impressions"

The parent_tag_id contains the id of the containing element for the list of entries, like this (assuming your id is called li-template):

parent_tag_id="li-template"

Here is an example ExpressionEngine template showing a main page and an embedded listing template. First, here's a snippet of markup from the main page:

Your Recently Viewed Products

{embed="shop/lasting_impressions_list"}   
 

... and here's the contents of the embedded template shop/lasting_impressions_list:

{exp:lasting_impressions_pro:load_js load_jquery="false"}

{exp:lasting_impressions_pro:form channel="products"
                                  status="open"
                                  use_ajax="yes"
                                  listing_template="shop/lasting_impressions_list"
                                  parent_tag_id="lasting_impressions_ajax"
                                  submit_value="Remove this entry ..."
                                  use_html5="yes"
                                  display_order="recent"}
  {title}

    ... any of your custom channel fields ...

  {submit_button}

  Viewed {lasting_impressions_pro:view_count} times

   Last viewed on {lasting_impressions_pro:last_view format="%D,%F %d, %Y - %g:%i:%s"}

{/exp:lasting_impressions_pro:form}

Reports

Version 3: View reports on tracked Channel Entries.

Navigate to the control panel and view the  Lasting Impressions Pro Module page.  You will see two buttons in the top right hand corner: select "Reports".

Lasting Impressions Reports Screen

Once in the reports view you will see a report which shows each view of a tracked entry.  The results are paginated with 25 results per page.  You can view the statistics unadulterated or you can view the totals for each tracked entry by choosing the relevant report from the drop down list "Report Type:".

You can also export the data in CSV format by clicking on the "Export" button.

The "Purge All Data" button is there should you wish to delete all your data and start again with a clean slate.  We would recommend that you do this AFTER having performed and export!

NB: On a busy website the report data could grow quite large so we highly recommend that you check back regularly and purge the data to ensure your database performance isn't affected.

Lasting Impressions is available to buy from ExpressionEngine

See our software licence