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

Forums / Developing with Sitefinity / how to use adwords conversion code

how to use adwords conversion code

7 posts, 0 answered
  1. Mart
    Mart avatar
    66 posts
    Registered:
    10 Aug 2006
    26 Feb 2010
    Link to this post
    Hello,

    after making a campaign in google adwords I receive a code from google i should paste in the body of het landing page.
    I made a landing page in with a existing  master page and theme and a general content.

    Where can I put the code from google?
    Google says it should be between the <body></body> tags

     <!-- Google Code for opleiding Conversion Page -->
    <script type="text/javascript">
    <!--
    var google_conversion_id = xxx;
    var google_conversion_language = "xxl";
    var google_conversion_format = "xx";
    var google_conversion_color = "xxx";
    var google_conversion_label = "xxx";
    var google_conversion_value = x;
    //-->
    </script>
    <script type="text/javascript" src="http://www.googleadservices.com/pagead/conversion.js">
    </script>
    <noscript>
    <div style="display:inline;">
    <img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/xxx/?label=xxx&amp;guid=ON&amp;script=0"/>
    </div>
    </noscript>
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    28 Feb 2010
    Link to this post
    Hello Mart,

    Add the code before the </body> tag of each page you are planning to track. You can do this in the master page.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Mart
    Mart avatar
    66 posts
    Registered:
    10 Aug 2006
    28 Feb 2010
    Link to this post
    Hello Ivan,

    do I have to make a new masterpage for every adwords campaign then?
    For example I have a campaign for education and also have a campaign for a webshop
    Do I need separate masterpages then?

    Thanks,

    Mart 
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    28 Feb 2010
    Link to this post
    Hello Mart,

    You can add the code to the master page or create a simple user control which enters the script you have from google.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  5. Mart
    Mart avatar
    66 posts
    Registered:
    10 Aug 2006
    28 Feb 2010
    Link to this post
    do you have a sample for this simple control?
  6. Mart
    Mart avatar
    66 posts
    Registered:
    10 Aug 2006
    05 Mar 2010
    Link to this post
    Hello,

    any samples available on building a control for adwords?
  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    08 Mar 2010
    Link to this post
    Hi Mart,

    1. You can use GenericContent control to add the script to a given page. The code will be wrapped in the body of your page. You can drop GenericContent control on each page where you would like to have adwords.

    2. You could create a custom control where you set script src, imgae src and inside IText control you enter the variables. Then you can drop this control on each page where you would like to have adwords

    sample

    • Create a custom control with a designer
    [ControlDesignerAttribute("ScriptControlControlDesigner, App_Code")]
    public class ScriptControl : SimpleControl
    {
        public ScriptControl ()
        {
        }
     
        [System.ComponentModel.Category("ScriptControlParameters")]
         public string UrlSrc
        {
            get
            {
                return this._urlSrc;
            }
            set
            {
                this._urlSrc = value;
            }
        }
     
        [System.ComponentModel.Category("ScriptControlParameters")]
         public string EditorContent
         {
     
             get
             {
                 return this._EditorContent;
             }
             set
             {
                 this._EditorContent = value;
             }
         }
     
        public override void RenderBeginTag(System.Web.UI.HtmlTextWriter writer)
        {
            //
        }
     
        public override void RenderEndTag(System.Web.UI.HtmlTextWriter writer)
        {
            //
        }
     
         protected override void InitializeControls(System.Web.UI.Control controlContainer)
         {
             base.InitializeControls(controlContainer);
             if (Page == null || DesignMode)
             {
                 Label noDesignModeLabel = new Label();
                 noDesignModeLabel.Text = "NoDesignMode";
                 this.Controls.Add(noDesignModeLabel);
             }
             else
             {
                 HtmlGenericControl scriptControl = new HtmlGenericControl("script");
                 scriptControl.Attributes.Add("type", "text/javascript");
                 scriptControl.Attributes.Add("src", UrlSrc);
                 this.Page.Header.Controls.Add(scriptControl);
                
                 Literal showsContent = new Literal();
                 showsContent.Text = EditorContent;
                 Controls.Add(showsContent);
             }
         }
        
        private string _urlSrc;
        private string _EditorContent;
    }
    • Create a control designer that will be used to enter the script src and image src

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;
     

    public class ScriptControlControlDesigner : Telerik.Framework.Web.Design.ControlDesigner
    {
        public ScriptControlControlDesigner ()
        {
        }
     
        public override string LayoutTemplatePath
        {
            get
            {
                return templatePath;
            }
        }
     
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
     
            ContentTextBox.Text = ((TwitterControl)DesignedControl).EditorContent;
            ScriptUrl.Text = ((ScriptControl)DesignedControl).UrlSrc;
        }
     
        public override void OnSaving()
        {
            base.OnSaving();
            ((ScriptControl)DesignedControl).EditorContent = ContentTextBox.Text;
            ((ScriptControl)DesignedControl).UrlSrc = ScriptUrl.Text;
        }
     
        public TextBox ContentTextBox
        {
            get
            {
                return base.Container.GetControl<TextBox>("TextBox1", true);
            }
        }
     
     
     
        public TextBox ScriptUrl
        {
            get
            {
                return base.Container.GetControl<TextBox>("ScriptUrl", true);
            }
        }
     
     
     
        private string templatePath = "~/CustomControls/ScriptControlDesgnerTemplate.ascx";
    }



    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about 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
7 posts, 0 answered