I wrote this pull request just for this case. It applies profile cards to items based on rules in the rules engine.
https://github.com/Sitecore/Habitat/pull/341
Any rule you can write that analyzes your content, can be applied to this new rules engine to apply a profile to an item on the fly. It does not add it to the item directly. That would require you create a timer job to re-apply your profiles and handle new item added to the tree. What it does it add profile to items and score them during my RunRules pipeline on the item render.
In your case you are going to want to use existing rules or create new rules to evaluate your content based on your tagging. Then execute the proper profile card to be added if your content meets your required tag.
Code
The heart of the code is the ApplyProfileValue
class below. When it runs on an item is applies a profile card to an item. The full commit can be found Here
public class ApplyProfileValue<T> : RuleAction<T> where T : RuleContext
{
public string Profilecardkey { get; set; }
public override void Apply(T ruleContext)
{
Assert.ArgumentNotNull(ruleContext, "ruleContext");
Assert.IsNotNull(Tracker.Current.Session.Interaction, "Tracker interaction can not be null.");
var profileItem = ruleContext.Item?.Database.GetItem(this.Profilecardkey);
if (profileItem == null)
return;
ProcessProfile(profileItem, Tracker.Current.Session.Interaction);
}
private static void ProcessProfile(BaseItem profileItem, CurrentInteraction interaction)
{
if (profileItem?.Fields[Templates.ProfileCard.Fields.ProfileCardValue] == null) return;
var trackingFields = new List<TrackingField>
{
new TrackingField(profileItem.Fields[Templates.ProfileCard.Fields.ProfileCardValue])
};
var fields = (IEnumerable<TrackingField>)trackingFields;
TrackingFieldProcessor.ProcessProfiles(interaction, fields.FirstOrDefault());
}
}