Google Analytics code in Business Catalyst Website

Adobe Business Catalyst

Business Catalyst already includes a great reporting tool - but Google Analytics is still my prefered report engine. You can gain so much information about who and why people are visiting your business catalyst site - more importantly it can help you figure out why sales or contact forms are not being completed.

Eventually this page is going to hold all the tips I have about using Google Analytics with Business Catalyst, but for now I have one tip and that is how to add the analytics tracking code to your templates in a way that works with Business Catalyst and the Dreamweaver plugin Triangle.

Business Catalyst (BC) has a habit of decoding the tracking code and breaking it. (Those "%3C" you see in the google code are actually "<"  but they need to be encoded to work).

The problem comes in with this part of the tracker code:

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>

Notice the unescape() call - this is what tells the browser to decrypt the %3C - BC should not touch this - but it does.

So the work around I have been using is:

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write("<scr" + "ipt src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'></scr" + "ipt>");
</script>

Notice that I've pre-decoded the string, removed the call to unescape() and broken up the string.

The important part here is that you must break up the <script  tag into something like <scr" + "ipt  ... this stops the webbrowser from seeing the script tag until the javascript tells it to (with the document.write() ). If you skip this bit you google analytics code will still not work and you will probably get javascript errors on the page.



Share
  • Facebook
  • Google Bookmarks
  • Ask
  • LinkedIn
  • Socialogs
  • Wikio
  • Digg
  • Twitter
  • SlashDot
  • Reddit
  • MySpace
  • Del.icio.us
  • Blogter
  • BlogMemes
  • Yahoo Buzz






Google Analytics code in Business Catalyst Website | 0 comments | Create New Account
The following comments are owned by whomever posted them. This site is not responsible for what they say.


Gold Coast Aquarium Maintenance | Gold Coast Marine Fish | Gold Coast Tropical Fish
Jewel Jones - Counselling Service - Penrith, Richmond
 
     
 Copyright © 2017 Julian Kuiters
 All trademarks and copyrights on this page are owned by their respective owners.