1. Home
  2. Cookbook
  3. Campaigns
  4. Web layer showing number of recent views of item

Web layer showing number of recent views of item

Start/edit tracking of your product landing page

In order to successfully create such a banner, it is needed to start tracking attribute “product_id”. It is necessary to call “exponea.showBanner”, which will call for new web layer’s ID. Which ID to copy+paste will be explained in next steps. Overall, the code should look similar to following.

Snímka

Create report which will be used in banner

Create report showing “product_id” in rows and count customer as metric. Set grouping to “Top 1000” and define date filter to value you want to use in your banner. If you want to show how many people have seen the item in last 1 hour, the date filter will be set to last 1 hour. Once saved, copy the report ID from URL of the report to code (mentioned above) and banner below (mentioned below).

Snímka3
Snímka1

Create weblayer you want to show

Create new weblayer using notification template. Define the visuals and position where you want the banner to appear. Next, change the text in following format:

***Your_text*** {{ report_value_by_key('***ID of your report***', params.product_id) or 0 }} ***Your_text***

You need to copy+paste the same report ID you have copy+pasted into the exponea.showBanner call.

Snímka5

In Code JavaScript (JS) section add following code at the very top:

var n =  parseInt("{{ report_value_by_key('***ID_of_your_report***', params.product_id) or 0 }}");//if(n < ***n***) return;

 

Snímka4

For ID of your report use the same ID as used before. For ***n*** set up the minimum number of customers you want to show. If the number is lower then given number, the banner will not be shown.

In settings define to whom you want to display the banner.

Updated on October 9, 2017

Was this article helpful?

Related Articles