Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6711509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:08:54+00:00 2026-05-26T08:08:54+00:00

I’m trying to implement a behavioral analysis for targeted marketing on my ecommerce website.

  • 0

I’m trying to implement a behavioral analysis for targeted marketing on my ecommerce website. The basic idea is as follows (I assume the usage of MongoDB, but looking forward for the other recommendations):

  • every website Category has a list of associated tags to it,
  • every content Article also has a list of tags,
  • every User has an unique cookie ID assigned to him/her on the first visit,
  • every time the user browses a Category or reads an Article, we plan to increment the User-tag dictionary like this:

    db.tagviews.update(
        {_id: user_id},
        {$inc: {'tags.foo': 1, 'tags.bar': 1, 'tags.baz': 1}},
        true /* upsert */
    )
    

So if we want to see the interests of the particular user, we can fetch the tagviews document for him and look through the tags to see which ones has the most views.

However, I’ve stumbled on a pretty much trivial thing – how to fetch users, based on tags criteria. E.g. we’ve got Google Galaxy Nexus in stock for an attractive price, and want to send marketing emails to the users most interested in [android, phones, gadgets, google].

As far as I understand, we have to create indexes on every tags.* field in the tagviews collection, which is, of course, unacceptable. The other possible solution is to duplicate data in another dimension (incrementing tag-user combo instead of user-tag). But syntetic tests looks very unpromising in terms of disk space and flexibility.

What would be your suggestions to effectively fetch the most interested users based on tags criteria?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:08:55+00:00Added an answer on May 26, 2026 at 8:08 am

    From your example i understand that you are using tag names as keys (aka fields) in tagviews collection.

    Dont do that , which leaves you in the nightmare when you need to create indexes. Instead create tags as embedded doc within tagviews

     tagviews{
          _id : 'xxxx',
          tags : [
            {
               name : "foo",
               count : 0
            },
            {
               name : "bar",
               count : 0
            },
            {
               name : "baz",
               count : 0
            }   
          ]
    

    and you can effectively index this document by tag name to use it in your filters

    db.tagviews.ensureIndex('tags.name',1)
    

    And you can increment the specific tag view of a user by

    db.tagviews.update({_id : "userid" , "tags.name":'foo'},{$inc:{"tags.$.count":1}})
    

    when your user stumbled on his interests.

    So to your real question,

    how to fetch users, based on tags criteria. E.g. we’ve got Google
    Galaxy Nexus in stock for an attractive price, and want to send
    marketing emails to the users most interested in [android, phones,
    gadgets, google].

    you can filter it like

     db.tagviews.find({'tags.name':{$in : ['android', 'phones','gadgets','google'] }})
    

    This will retrieve all the users who are interested in above said tags.

    or even you can use count to filter most accurate data

    db.tagviews.find({'tags.name':{$in : ['android', 'phones','gadgets','google'] },'tags.count' : {$gt : 0 }})
    

    hope this helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post
I am trying to loop through a bunch of documents I have to put
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.