Search code examples
djangologgingclienttracking

Recommendations on tracking user browsing with Django


I'm developing a large scale consumer site with django for my masters project. Basically, I would like to track everything that a user searches for/clicks on etc, so as to make recommendations a'la amazon's "recommended for you" sections.

Are there any good resources for doing this? I don't know whether I should be storing this in logs, or in a model, or what. I've never done anything like this before.

I'm having trouble finding many resources to help me on this, perhaps because I don't really know what to even search for, so any suggestions or nudges in a direction would be most appreciated.


Solution

  • I'm currently using exactly this to keep a track of all my user and their activity,

    class ActivityLog(models.Model):
        actor = models.ForeignKey(settings.AUTH_USER_MODEL, null=True)
        action_type = models.CharField(max_length=50)
        act_meta = HStoreField(blank=True, null=True)
        timestamp = models.DateTimeField(auto_now_add=True)
    

    'act-meta' stores all the details particular to that user event. Since i didn't want this everywhere on my website, i'm not using it via middleware. But i'm using this for a recommendation system and it works just fine.