+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Google Website Optimizer for A/B testing through SF

Google Website Optimizer for A/B testing through SF

3 posts, 0 answered
  1. Duncan Evans
    Duncan Evans avatar
    122 posts
    Registered:
    07 Jul 2009
    22 Jun 2011
    Link to this post
    I want to do some A/B Testing using Google Website Optimizer and Sitefinity.

    As you know a GWO script must be placed between the <head> tags of the pages in the experiment. I'm looking for a control or module that will allow me to add it to the SF page and that will add the necessary tags to the <head> portion of the page.

    Does anyone know of anything or know how to achieve this?

    Thanks,
  2. Duncan Evans
    Duncan Evans avatar
    122 posts
    Registered:
    07 Jul 2009
    23 Jun 2011
    Link to this post
    I solved this with a control that can be added to the page:

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="ScriptBlock.ascx.cs" Inherits="UserControls_Custom__PageElements_ScriptBlock" %>
    <%@ Register Assembly="Telerik.Cms.Engine" Namespace="Telerik.Cms.Engine.WebControls"
        TagPrefix="sfWeb" %>
    <sfWeb:GenericContent runat="server" ID="GenericContent1" />

    using System;
    using System.ComponentModel;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using Telerik.Cms.Engine;
    using Telerik.Cms.Engine.WebControls;
    using Telerik.Framework.Web.Design;
    using Telerik.Web;
     
    [ControlDesignerAttribute("Telerik.Cms.Engine.WebControls.Design.GenericContentDesigner, Telerik.Cms.Engine")]
    public partial class UserControls_Custom__PageElements_ScriptBlock : System.Web.UI.UserControl, IGenericContent
    {
        #region Public Properties
     
        [Category("Tag Specifications"), Description("")]
        public virtual string Tag
        {
            get
            {
                object obj = this.ViewState["Tag"];
                if (obj != null)
                {
                    return Convert.ToString(obj);
                }
                return "script";
            }
            set
            {
                this.ViewState["Tag"] = value;
            }
        }
     
        [Category("Tag Specifications"), Description("")]
        public virtual string Type
        {
            get
            {
                object obj = this.ViewState["Type"];
                if (obj != null)
                {
                    return Convert.ToString(obj);
                }
                return "text/javascript";
            }
            set
            {
                this.ViewState["Type"] = value;
            }
        }
     
        #endregion
     
        protected void Page_Load(object sender, EventArgs e)
        {
            HtmlGenericControl Include = new HtmlGenericControl(Tag);
            Include.Attributes.Add("type", Type);
            Include.InnerHtml = GenericContent1.Content;
     
            Page.Header.Controls.Add(Include);
     
            GenericContent1.Visible = false;
        }
     
        #region IGenericContent Members
     
        [CmsBrowsable(false)]
        [CmsPersistable(true)]
        public string Content
        {
            get
            {
                return GenericContent1.Content;
            }
            set
            {
                GenericContent1.Content = value;
            }
        }
        [Browsable(false)]
        public Guid ContentID
        {
            get
            {
                return GenericContent1.ContentID;
            }
            set
            {
                GenericContent1.ContentID = value;
            }
        }
        public string ProviderName
        {
            get
            {
                return GenericContent1.ProviderName;
            }
            set
            {
                GenericContent1.ProviderName = value;
            }
        }
        [Browsable(false)]
        public IContent SharedContent
        {
            get
            {
                return this.GenericContent1.SharedContent;
            }
        }
        public bool UseStagedVersion
        {
            get
            {
                return GenericContent1.UseStagedVersion;
            }
            set
            {
                GenericContent1.UseStagedVersion = value;
            }
        }
        [CmsBrowsable(false), CmsPersistable(true)]
        public bool HasDynamicLinks
        {
            get
            {
                return GenericContent1.HasDynamicLinks;
            }
            set
            {
                GenericContent1.HasDynamicLinks = value;
            }
        }
        public string GetItemUrl(string provider, Guid id, bool resolveAsAbsoluteUrl)
        {
            return GenericContent1.GetItemUrl(provider, id, resolveAsAbsoluteUrl);
        }
        public void RenderBinaryContent(HtmlTextWriter writer)
        {
            GenericContent1.RenderBinaryContent(writer);
        }
        public void RenderTextContent(HtmlTextWriter writer)
        {
            GenericContent1.RenderTextContent(writer);
        }
     
        #endregion
    }
  3. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    23 Jun 2011
    Link to this post
    Hi Duncan,

    There would be some issues with this case - implementing IGenericContent in a user control. Generally you should wrap GeneriContent in a custom control by inheriting directly from GenericContent class.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
3 posts, 0 answered