CornerPixel Blog RSS 2.0

# Monday, September 08, 2008

This won't be the biggest post ever, but it is important none the less.  I have been as of late creating sites with Adobe Dreamweaver and my users have been using Contribute CS3 to edit them.  Now I still hand coded the site for the most part, but I did use the template system that Dreamweaver has and it was pretty effective.

My customer wanted to make sure I put his Google Analytics code into the new site so he could continue monitoring his website.  I didn't think there would be any issue with this and I inserted the Google Analytics code right before the end body tag.

My next step was to allow my user to edit in Contribute CS3.  I got a call later from my customer stating that his page was now looking funny and he was getting extra parenthesis at the bottom of the page.  I looked at the source and saw that Contribute had changed the following code.

type='text/javascript'%3E%3C/script%3E"));

to the literal

type='text/javascript'></script>"));

So now we end up getting  ")); at the bottom of the page.  That isn't good.  It turns out that Adobe Contribute CS3 enforces a level of XHTML compliance, which is more than the Google Analytics code complies with.  Hopefully in the near future Google will change it's code, but in the mean time if you just place the code in the head of the page, Contribute will not change the code.

The other solution is to remove the HTTP/HTTPS auto detection and just use the appropriate script tag for your site.  I don't like this solution because it requires more work, but if you are inclined to do it that method then below is the code for each.

For HTTP:
<script type="text/javascript" src="http://www.google-analytics.com/
ga.js"></script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-XXXX-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>

For HTTPS:
<script type="text/javascript" src="https://ssl.google-analytics.com/
ga.js"></script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-XXXX-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>

Well I hope that helps

~Michael

Monday, September 08, 2008 5:56:28 PM (Pacific Standard Time, UTC-08:00)

#       Comments [0] - Trackback

Code | Web Standards

Comments are closed.

Archive

<July 2010>
SunMonTueWedThuFriSat
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567

Email Subscription

Sign up to get the CornerPixel Blog delivered to your email.

About the Author

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

Sign In

Statistics

Total Posts: 52
This Year: 3
This Month: 0
This Week: 0
Comments: 28