Thursday, February 2, 2012

Delegate Control to Inject Google Analytics in MOSS

Hi Guys,

i want to load js for Google analytics for some site and don't want to load for some site so thinking of doing this using delegate control so users can control through feature activation and deactivation.i did something like this for banner image so will this approch work to load js too ?

if there is other way please advise




You can opt for 2 set of master pages. One without scripts included, the other one having the Google Analytic implementation


Reply 2


I am trying to add JS in Master page using Delegate Controls but its not is code i have written.

Please advise


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.SharePoint;
namespace WSPBuilderProject1.SharePointRoot.Template.ControlTemplates.PhilaGov
public partial class PhilaGovGA : UserControl {
protected void Page_Load(object sender, EventArgs e) {
string _url = SPContext.Current.Web.Url;
protected override void CreateChildControls() {
this.Controls.Add(new LiteralControl(@"<script type='text/javascript'>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '#12323232']);



Once i enable feature i dont see this code in head section of master page.

Please advise




No comments:

Post a Comment