Book Image

SharePoint 2013 WCM Advanced Cookbook

By : JOHN CHAPMAN
Book Image

SharePoint 2013 WCM Advanced Cookbook

By: JOHN CHAPMAN

Overview of this book

Table of Contents (19 chapters)
SharePoint 2013 WCM Advanced Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Adding stored analytics tracking code to pages with an AdditionalPageHead delegate control


With the analytics tracking code being stored from the previous recipe, we will use an AdditionalPageHead delegate control to insert the snippet of analytics tracking code on each page.

Getting ready

For this recipe, we should already have the settings page created in the Storing analytics tracking code with a site collection settings page recipe.

How to do it...

Follow these steps to add the stored analytics tracking code with a delegate control:

  1. Open the project created in the Creating a Visual Studio solution for custom delegate controls recipe of this chapter in Visual Studio.

  2. Add a new class to our Controls folder.

  3. Set the access modifier of our new class to public and inherit from the UserControl base class:

    public class CustomAnalyticsCode : UserControl
  4. Add a constant string with the name of the property we are storing the analytics code with as follows:

    private const string PropertyName = "CustomAnalyticsCode...