SQL for DotNetNuke PageHeaderText Update for Google Analytics#

I have several sites running off a single DotNetNuke installation and I wanted to add the Google Analytics Javascript to several of the sites. I had a few options: 

  1. I could change default.aspx to include the JavaScript code in the HTML head
  2. I could incorporate the Urchin Javascript in a DNN Skin
  3. I could go I could go into each pages Page Settings>Advanced Settings>Page Header Tags and drop the JavaScript into the textbox
  4. Just run a SQL statement

Option 1 does not work because all installations would have the same JavaScript and I could not be site specific with the Google Analytics Site ID. Option 2 is probably the best option but I am lazy and did not want to update each skin and upload them each to the site. Option 3 is just ridiculous for a few of our larger sites and would take forever...so, I picked Option 4, the quick sql statement:

UPDATE Tabs SET PageHeadText = '<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
           </script>
           <script type="text/javascript">
                _uacct = "UA-xxxxxx-x";
                urchinTracker();
           </script>'
 WHERE (PortalID = 0)

Before you use this sql update statement against your DNN database, make sure you update your Google Analytics ID, "UA-xxxxxx-x", and PortalID #.

This will automatically change all pages for that portal to include the Google Urchin JavaScript. If you do not want certain pages such as the Admin pages to include this JavaScript, simply filter out any by ParentID's 

Example:

UPDATE Tabs SET PageHeadText = '<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
           </script>
           <script type="text/javascript">
                _uacct = "UA-xxxxxx-x";
                urchinTracker();
           </script>'
 WHERE (PortalID = 0) AND ParentID <> '38'

You could easily use this same script to add other HTML head code. Hope that helps!

11/28/2005 11:14:43 PM (Eastern Standard Time, UTC-05:00) #    Comments [0]  |  Trackback
Tracked by:
"Updated SQL Statement for inserting Google Analytics JavaScript into Tabs PageH... [Trackback]

 

All content © 2008, Xfernal
On this page
This site
Calendar
<October 2008>
SunMonTueWedThuFriSat
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678
Archives
Sitemap
Blogroll OPML
Scott Schecter
Entropy Expounded
Venexus DotNetNuke Blog
Articles, Code Snippits, and News from the DNN frontline.
Disclaimer

Powered by: newtelligence dasBlog 1.8.5223.1

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Send mail to the author(s) E-mail

Theme design by Jelle Druyts


Pick a theme: