Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Google-analytics and SSL


germ

Recommended Posts

Posted

If you have google-analytics java script on your site, it will give you the "Do you want to display the nonsecure items?" popup if you install an SSL certificate.

 

Since Google doesn't index SSL pages, here's a way to get PHP to ignore the code when in SSL mode, and you won't get the nonsecure items popup:

 

<?php
if ( $request_type != 'SSL' ) {
?>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-xxxxxxx-x";
urchinTracker();
</script>
<?php
}
?>

Wrap the PHP code around your google-analytics script as shown above.

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Posted

if you use new code of Google-analytics it will support the SSL - secure protocol.

 

<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>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-xxxxx-x");
pageTracker._initData();
pageTracker._trackPageview();
</script>

Please read this line: Do you want to find all the answers to your questions? click here. As for contribution database it's located here!

8 people out of 10 don't bother to read installation manuals. I can recommend: if you can't read the installation manual, don't bother to install any contribution yourself.

Before installing contribution or editing/updating/deleting any files, do the full backup, it will save to you & everyone here on the forum time to fix your issues.

Any issues with oscommerce, I am here to help you.

Posted

If the code isn't inserted properly, it can cause the Java Script error:

 

_gat is not defined

 

I've seen that on some sites.

 

I Google'd that error, and it said to check for extra spaces in the code.

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Posted

I found a fix for the _gat os not defined error:

 

<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>
<script type="text/javascript">
if (typeof(_gat) == "object") { 
 var pageTracker = _gat._getTracker("UA-xxxxx-x");
 pageTracker._initData();
 pageTracker._trackPageview();
} 
</script>

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

  • 1 month later...
Posted

How would I make the following Statcounter code "SSL Safe"?

I really have no idea about Javascript :(

<!-- Start of StatCounter Code -->
<script type="text/javascript">
var sc_project=34XXX4; 
var sc_invisible=1; 
var sc_partition=38; 
var sc_security="12eXXXc7"; 
</script>

<script type="text/javascript" 

src="http://www.statcounter.com/counter/counter_xhtml.js"></script><noscript><div 

class="statcounter"><a href="http://www.statcounter.com/free_invisible_web_tracker.html" 

target="_blank"><img class="statcounter" src="http://c39.statcounter.com/34XXXX4/0/1XXX0c7/1/" 

alt="free web tracker" ></a></div></noscript>
<!-- End of StatCounter Code -->

 

I believe that this code is in part responsibly for me "non-secure items" Messages.

Open Source Newsletter: PhPList

Open Source Questionnaire: Lime Survey

Posted
<?php
if ( $request_type != 'SSL' ) {
?>

<!-- Start of StatCounter Code -->
<script type="text/javascript">
var sc_project=34XXX4; 
var sc_invisible=1; 
var sc_partition=38; 
var sc_security="12eXXXc7"; 
</script>

<script type="text/javascript" 

src="http://www.statcounter.com/counter/counter_xhtml.js"></script><noscript><div 

class="statcounter"><a href="http://www.statcounter.com/free_invisible_web_tracker.html" 

target="_blank"><img class="statcounter" src="http://c39.statcounter.com/34XXXX4/0/1XXX0c7/1/" 

alt="free web tracker" ></a></div></noscript>
<!-- End of StatCounter Code -->

<?php
}
?>

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Posted

Thank you! That works great, but:

here's a way to get PHP to ignore the code when in SSL mode

Does that mean that I wont receive anymore Stats from the Pages that are requested in SSL?

Open Source Newsletter: PhPList

Open Source Questionnaire: Lime Survey

Posted

True.

 

No more stats from SSL pages.

 

But you really have little choice, unless they upgrade the code to work in SSL mode.

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Posted

awesome...works great germ, thanks....seems like google is still tracking my pages....lets hope i didnt break anything

Vetty

Chief Creative Officer

ONO Tea |

Posted

I don't want to rain on your parade, but I've looked at your HTML source and I don't see Google Analytics anywhere.....

:blush:

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Posted

Which file do you put your code in ?

 

I have tried in several places and although it tracks stats it never appears in between the body tags which is where I am it SHOULD go ?

  • 2 months later...
Posted
I have google analytics code in my footer and have not experience the non-secure warning. Something wrong?

 

My site is at http://shashinki.com/shop/

 

 

I did the same thing and found out that if you don't have any banners turned on it won't work.

 

I have banners for some affilate programs on mine and was getting the non secure errors and such. I also am using statcounter and google analytis. I made a separate html file and just put this in the includes/footer:

 

<?php include("http://yoursite.com/includes/statcounter.html"); ?>

 

Then I put the statcounter code and my google analytic code in my statcounter.html file.

 

So I just updated the code for both in my statcounter.html file Thanks guys ! works like a charm.

 

But I have to have banners turned on for all of it to work.

 

 

I also have a question that is sort of on topic.

 

I have a comodo ssl and they gave me this neat js code to show the COMODO SSL logo at the bottom right corner of mysite on all pages. The only way I could figure out how to install it was putting it in the header. But I couldn't figure out how to stop the SSL errors. I was getting one that said the names didn't match or something. I think the browser was reading my cert but detected the logo coming from another ssl somewhere else or something like that.

 

Is there a work around?

 

Thanks

Chris

 

www.hartsbatteries.com

Posted

oops double post some how.... :rolleyes:

 

Also.. I meant to say that I put the comodo code in my footer not header.

  • 1 month later...
Posted

Hi,

 

Not sure what all you guys are on about. I don't seem to have google-analytics or any of the sort in my scripts unless I'm looking at something else. I too had the same problem on Firefox, i.e. I got the padlock but with the red exclamation mark and the usual secure/non-secure popup.

 

After a bit of investigation, I finally resolved it and it was extremely simple. All you need to do is add the HTTPS SERVER name in the configure.php file found in the /includes folder.

 

So at the top of this php script you would add it as follows:

 

define('HTTPS_SERVER', 'https://your-secure-https-link.co.uk/');

 

I tested this under Firefox and the exclamation mark is gone and I also tested it under IE as before there was no popup and no padlock, now there is.

 

Don't forget, after adjusting this code, you need to clear your Firefox cache otherwise it would not register it. Not sure about IE, but do that too if it doesn't work.

 

I hope this helps. :rolleyes:

 

antonitus

Posted

Hello,

 

Can someone help me out?

 

I have checked both Google_analytics and HTTPS_SERVER and they are correct on my scripts. But I still get the warning message when I logon or try to check out something.

 

google-analytics:

 

<!-- This part was added to include the google analytics 5/17/08 -->
<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>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-4444744-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>

 

HTTPS_SERVER

 

  define('HTTP_SERVER', 'http://www.chamtechinc.com'); // eg, [url="http://localhost"]http://localhost[/url] - should not be empty for productive servers
 define('HTTPS_SERVER', 'https://www.chamtechinc.com'); // eg, [url="https://localhost"]https://localhost[/url] - should not be empty for productive servers
 define('ENABLE_SSL', true); // secure webserver for checkout procedure?
 define('HTTP_COOKIE_DOMAIN', 'http://www.chamtechinc.com');
 define('HTTPS_COOKIE_DOMAIN', 'https://www.chamtechinc.com');  
 define('HTTP_COOKIE_PATH', '/');
 define('HTTPS_COOKIE_PATH', '/');
 define('DIR_WS_HTTP_CATALOG', '/');
 define('DIR_WS_HTTPS_CATALOG', '/');

 

Thanks in advance

Posted

I found the problem in my footer.php. There were references to HTTP and I change them to HTTPS and it works now.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...