User Affinity
The “User Affinity” system is designed to be a way to recommend content to users based on their individual interests. A user’s interests can be determined by any number of business rules and stored in the user affinity system to be injected in a user’s newsfeed. Custom implementations can also be created to use the user’s weighted interests to build “suggestion” areas.
How It Works
Content Categories drive the backend of the “User Affinity” system. The “User Affinity” system stores a category’s identifier and a weight variable to rank the category against other categories in relation to the user’s interests. Content categories can be added in the control panel. (Plugins -> Content Categories)
Creating User Affinity Relations with Trigger Events
Clients can create custom user affinity relations with the trigger events page. (Options -> Trigger Events) Using the trigger event system, clients can implement any number of business logic flows to increment the user affinity relations. For example, when a user tags a piece of content as “Dog”, the client response system could increment “Dog” two weight points and “Beagle” and “Collie” one weight point. With this type of system, the user who created the piece of content about dogs would then be recommended not only content tagged as “Dog”, but also content tagged as “Beagle” and “Collie”.
Fetching a user’s tag affinity
To increment a user’s tag affinity, you will first need to retrieve a list of the user’s current affinity relations.
1 |
http://services.onesite.com/rest/svcTagMaster?action=getUserTagAffinity&userID=[user_id]&devkey=[devkey] |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<!--?xml version="1.0" encoding="UTF-8" standalone="yes"?--> <svctagmaster> <getusertagaffinity> <status> <code>1</code> <message>Success</message> </status> <result> <total/> <page/> <perpage/> <items> <item> <user_tag_id>1</user_tag_id> <tag_master_id>326459</tag_master_id> <user_id>4686733</user_id> <weight>5</weight> </item> </items> </result> </getusertagaffinity> </svctagmaster> |
Incrementing a User’s Tag Affinity
Once you have a user’s tag affinity, you can then increment the weights as needed and perform any needed update calls.
1 |
https://services.onesite.com/rest/svcTagMaster?action=updateUserTagAffinity&tagID=326459&userID=[user_id]&weight=6&devkey=[devkey] |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<!--?xml version="1.0" encoding="UTF-8" standalone="yes"?--> <svctagmaster> <updateusertagaffinity> <status> <code>1</code> <message>Success</message> </status> <result> <total/> <page/> <perpage/> <items> <user_tag_id>1</user_tag_id> <tag_master_id>326459</tag_master_id> <user_id>4686733</user_id> <weight>6</weight> </items> </result> </updateusertagaffinity> </svctagmaster> |
Getting Content Category Identifiers
To work with the “User Affinity” service calls you will need the content category identifiers for your network. You can retrieve these from svcTagMaster->listContentCategories()
1 |
https://services.onesite.com/rest/svcTagMaster?action=listContentCategories&nodeID=[node_id]&xrefType=all&devkey=[devkey] |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <svcTagMaster> <listContentCategories> <status> <code>1</code> <message>Success</message> </status> <result> <total>4</total> <page>1</page> <perPage/> <items> <item> <tag_node_id>326457</tag_node_id> <tag_word>Mangos</tag_word> <tag_word_tt>Mangos</tag_word_tt> <parent_tag_id>0</parent_tag_id> </item> <item> <tag_node_id>326461</tag_node_id> <tag_word>Oranges</tag_word> <tag_word_tt>Oranges</tag_word_tt> <parent_tag_id>0</parent_tag_id> </item> <item> <tag_node_id>326455</tag_node_id> <tag_word>Pineapples</tag_word> <tag_word_tt>Pineapples</tag_word_tt> <parent_tag_id>0</parent_tag_id> </item> <item> <tag_node_id>326459</tag_node_id> <tag_word>Test1234</tag_word> <tag_word_tt>Test1234</tag_word_tt> <parent_tag_id>0</parent_tag_id> </item> </items> </result> </listContentCategories> </svcTagMaster> |