2

I'm using Sitecore 9.0.2 and I'm attempting to use tags in Sitecore analytics to track if a particular modal has been closed, so it doesn't reappear. This is working within a session, but when the browser is closed and reopened, the modal reappears. I did confirm via Fiddler that the SC_ANALYTICS_GLOBAL_COOKIE value is the same in both sessions.

I created an extension to take my tag ID and set a value of "1" to it (I mainly care if the tag exists). This is my set code:

    public static void SetTag(this string tagId, string value) {
        Contact contact = Tracker.Current?.Contact;

        if (contact == null) {
            Logger.Info("SetTag: Contact not found");
            return;
        }

        ITag tag = contact.Tags.Find(tagId);

        if (tag == null) {
            contact.Tags.Set(tagId, value);
        }
    }

I noticed that anonymous contacts don't show in Experience Profile, which I remember they changed by default in 8.2.3. I'm not sure if that's related and I just need to turn the anonymous tracker on or if using tags for this purpose isn't best practice because they don't persist session to session (at least for anonymous users).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.