Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 387839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:42:41+00:00 2026-05-12T15:42:41+00:00

I’m trying to include the Google Website Optimizer JavaScript code, below, in a Zope3

  • 0

I’m trying to include the Google Website Optimizer JavaScript code, below, in a Zope3 page template. It’s used for for A/B testing.

However, the template html parser, which I believe is the standard Python HTMLParser module, throws the following error:

raise PTRuntimeError(str(self._v_errors))
- Warning: Compilation failed
- Warning: <class 'HTMLParser.HTMLParseError'>: bad end tag: u"</sc'+'ript>", at line 45, column 44
PTRuntimeError: ['Compilation failed', '<class \'HTMLParser.HTMLParseError\'>: bad end tag: u"</sc\'+\'ript>", at line 45, column 44']

As I see it I have two options:

  • Rewrite the code so it passes (my JS-foo is weak, no idea where to start).

  • Make HTMLParser ignore the code. I’ve tried CDATA tags with no success. I’ve also tried putting the js in an external file and linking to it, but this seems to break the optimizer functionality.

The suspect code:

<!-- Google Website Optimizer Control Script -->
<script>
<![CDATA[
function utmx_section(){}function utmx(){}
(function(){var k='1010538027',d=document,l=d.location,c=d.cookie;function f(n){
if(c){var i=c.indexOf(n+'=');if(i>-1){var j=c.indexOf(';',i);return c.substring(i+n.
length+1,j<0?c.length:j)}}}var x=f('__utmx'),xx=f('__utmxx'),h=l.hash;
d.write('<sc'+'ript src="'+
'http'+(l.protocol=='https:'?'s://ssl':'://www')+'.google-analytics.com'
+'/siteopt.js?v=1&utmxkey='+k+'&utmx='+(x?x:'')+'&utmxx='+(xx?xx:'')+'&utmxtime='
+new Date().valueOf()+(h?'&utmxhash='+escape(h.substr(1)):'')+
'" type="text/javascript" charset="utf-8"></sc'+'ript>')})();
]]>
</script><script>utmx("url",'A/B');</script>
<!-- End of Google Website Optimizer Control Script -->
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T15:42:41+00:00Added an answer on May 12, 2026 at 3:42 pm

    Given the parser’s weakness, you could try breaking up the parts of the CDATA that it’s trying to interpret as tags, e.g. where you now have </sc'+'ript>' try <'+'/sc'+'ript>' etc (+ does string catenation in JS, just like in Python, so it will put back together again the tags you break up this way, just like the tags that are already broken up in the original).

    If that keeps giving parse errors, lose the CDATA and change every < into &lt;, every > into &gt; — not sure if JS will handle that but it’s worth a try… good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 215k
  • Answers 215k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can enter the exception as a module-level SuppressMessage attribute.… May 12, 2026 at 10:58 pm
  • Editorial Team
    Editorial Team added an answer The information can be found in the setuptools documentation for… May 12, 2026 at 10:58 pm
  • Editorial Team
    Editorial Team added an answer Try escaping the single quotes as &apos;. E.g.: <setdynvars sourcetype="eval"… May 12, 2026 at 10:58 pm

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want use html5's new tag to play a wav file (currently only supported
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
In order to apply a triggered animation to all ToolTip s in my app,
I have a French site that I want to parse, but am running into

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.