Skip to content

Instantly share code, notes, and snippets.

@alasvant
Created February 23, 2019 13:05
Show Gist options
  • Save alasvant/718253abacae7157d4750c5a8a212a02 to your computer and use it in GitHub Desktop.
Save alasvant/718253abacae7157d4750c5a8a212a02 to your computer and use it in GitHub Desktop.
Sample GTM selection factory to pre-populate category selection options (Episerver Forms demo).
using EPiServer.Shell.ObjectEditing;
using System.Collections.Generic;
namespace AlloyWithFind.Business.SelectionFactories
{
/// <summary>
/// Selection factory to return GTM category values for form submission event.
/// </summary>
public class GtmCategorySelectionFactory : ISelectionFactory
{
/// <summary>
/// Gets the GTM category values.
/// </summary>
/// <param name="metadata"></param>
/// <returns>GTM category values</returns>
public IEnumerable<ISelectItem> GetSelections(ExtendedMetadata metadata)
{
// not localized for now
return new List<ISelectItem>
{
new SelectItem{ Text = "CustomerProfile", Value = "customerprofile"},
new SelectItem{ Text = "Commercial", Value = "commercial"},
new SelectItem{ Text = "Other", Value = "other"}
};
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment