[ic] Track Product Views

Andrew Metcalfe interchange-users@icdevgroup.org
Fri Sep 6 11:54:22 2002


> -----Original Message-----
> From: interchange-users-admin@icdevgroup.org
> [mailto:interchange-users-admin@icdevgroup.org]On Behalf Of Michael
> Goldfarb

>
> [query st=db sql="update products
> set number_accessed = '[calc][item-field number_accessed] + 1[/calc]',
> last_accessed = '[convert-date raw=1][/convert-date]'
> where sku = '[item-code]'
> "]
> [/query]

You could even take it a step farther, create a table called reports, and
put a query on flypage like this:

create table reports (
userid varchar(32)
sku    varchar(32)
date 	 dateTime
}

[query st=db sql="insert reports
userid, sku, date
values('[userdb userid]','[convert-date raw=1][/convert-date]', )
date = '[convert-date raw=1][/convert-date]','[item-code]')
"]

Then you could query based on a certain timeframe, or per users, or number
of times viewed before purchasing, etc.  This table will grow quite large,
so make sure you have it indexed properly.

I'm not really sure about the capabilities of mySQL, but in oracle you could
do something like:

select count(userid,sku) from reports
group by userid,sku
having date > '01/01/02'
order by count(userid,sku) desc;

which would give you a report of how many times a user viewed a certain
product in 2002, ordered by number of views.

You'll find the more comfortable you get with SQL, you'll find it's an
incredibly powerful tool for managing and reading data.

_Am