Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 573
  • Last Modified:

Smarty Template website and Google Analytics

Hi, I got some great help this morning, unfortunately my problem of Google analytics not working within a smarty templates website remains.
I was told to add in tags {literal} see below, but this does not seem to have worked.  Can anyone help anymore? :)
{literal}
<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-xxxxxx-x");
pageTracker._trackPageview();
</script
{/literal}

Open in new window

0
wood1e
Asked:
wood1e
  • 2
  • 2
1 Solution
 
solutionDriverCommented:
Hello wood1e,

here's a trap that you want to be aware of: Is the smarty tag delimiter in this case the default {...},
or is the default changed in the given application. E.g. the OXID eSales shop system uses [{ ... }] instead.

Is the Google javascript code visible as expected in the source code of the produced webpage?

If yes, then the problem is not the smarty environment, but either the code or something is wrong with
the getting over the data to Google Analytics.

What happens is you exchange 'document.write()' in the javascript with alert()?
Does the link shown in the alert box work? What does it look like?

Best,

 sd

0
 
wood1eAuthor Commented:
Right not sure what you meean, but I have just gone to the website and view source, and yes I can see the code!!

So maybe thinks will be ok in the morning, maybe analytics is just being slow at picking up the code?
I have copied and pasted the code below...loooks ok?
<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">
try {
var pageTracker = _gat._getTracker("UA-XXXXXX-1");
pageTracker._trackPageview();
} catch(err) {}</script>

Open in new window

0
 
solutionDriverCommented:
OK, I tested the script, and it looks all good.

I assume that you obfuscated the tracking ID ("UA-XXXXXX-1") just for this board, yes?

The XXXXXX is where the ID for your site has to go. Just to make sure. ;-)

sd
0
 
wood1eAuthor Commented:
yeah you are right, appears there was just a delay with google, me getting all excited!!
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now