Hi,

My Google Analytics module works fine. But when i view the page source of my drupal site, i see two closing script tags for the Google Analytics script as follows:

<script type="text/javascript"> 
<!--//--><![CDATA[//><!--
var _gaq = _gaq || [];_gaq.push(["_setAccount", "UA-20414996-1"]);_gaq.push(["_trackPageview"]);(function() {var ga = document.createElement("script");ga.type = "text/javascript";ga.async = true;ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";var s = document.getElementsByTagName("script")[0];s.parentNode.insertBefore(ga, s);})();
//--><!]]>
</script> 

</script>

I have to remove the duplicate

. How do i do it?

Thanks

Comments

hass’s picture

Category: bug » support
Status: Active » Fixed

This is not from the GA module.

jorism’s picture

Version: 6.x-3.0 » 6.x-2.0
Status: Fixed » Active

I had a similar problem with a javascript that protects e-mail addresses against spam.
In my case, the whole < script >< / script > block gets duplicated

For this specific case, I found a 'dirty patch': just surround your scripting code by a check whether a variable used in the script already exists.
For example:

if (typeof ML=="undefined")
{
MH = "hello";
...
}

On the second pass, the variable already exists and so the script will not be executed again...

(It's not from GA, so this thread can be set to fixed, I am sorry for the inconvenience)

ice5nake’s picture

Version: 6.x-2.0 » 6.x-3.1

I am having the same problem with my Google Analytics script.

This has to be getting assigned to the closure template variable twice somehow.

Not sure if this is pertinent but I am using a custom Zen sub-theme.

I'll help in anyway I can.

hass’s picture

Check if you Zen theme have this tag in the templates, please. It seems not from core.

hass’s picture

Status: Active » Fixed
ice5nake’s picture

I suspect the problem is another module not implementing something correctly. I'll try to help by looking into this if I get time.

I have lightbox2, sharethis, cufon, and admin menu which all appear to add code to the footer but only googleanalytics is showing up twice.

Although I strongly suspect this is the cufon modules fault as described here: http://drupal.org/node/591838 and mentioned here http://drupal.org/node/734630

hass’s picture

Status: Fixed » Closed (duplicate)

cufon is big sh**. There is an issue with a patch in the cufon queue... this is therefore a duplicate.

hass’s picture

You need latest DEV. It must be later than beta4...

hass’s picture

Project: Google Analytics » Cufón
Version: 6.x-3.1 » 6.x-1.0-beta4
Category: support » bug
Priority: Normal » Critical
Status: Closed (duplicate) » Active
kristofdg’s picture

Hi
I also had to problem with duplicate google_analytic scripts and tracked it down to this line: $vars['closure'] = theme('closure') in cufon_preproccess_page. See code snippet.

function cufon_preprocess_page(&$vars) {
  foreach (_cufon_discover_fonts() as $filename => $name) {
    drupal_add_js($filename, 'module');
  }
  $selectors = variable_get('cufon_selectors', array());
  drupal_add_js(array('cufonSelectors' => $selectors), 'setting');

  $vars['scripts'] = drupal_get_js();
  //This line caused hook_footer to be called twice why is this here in the first place?
 //$vars['closure'] = theme('closure'); 
}
troky’s picture

Status: Active » Fixed

Probably fixed in 6.x-1.x-dev.

Re-open issue if problem persists.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.