if statement crashes module...

rfuest6134
rfuest6134 Community Member Posts: 43
When adding an if statement in a header script which works fine so far, the module crashes and is published without layout and graphics. What might be wrong? I can not see an error in the JavaScript.

I would linkt to add an opt out function for (not) tracking user activities with piwik. The piwik code works fine. When sourrounding die piwik code with an if statement reacting on a userdefined variable (line 5 and 24), eyerything goes wrong.
<!-- Seitentitel anpassen -->
document.title = VarCurrentTitleName.getValue() + ": " + VarCurrentPageName.getValue();
<!-- Piwik -->
<!-- wenn kein opt-out -->
if (VarPiwikStatus.getValue() == "on") {
var _paq = _paq || [];
(function(){
var u=(("https:" == document.location.protocol) ? "https://piwik.URL/" : "http://piwik.URL/");
_paq.push(['setSiteId', 15]);
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setVisitorCookieTimeout', '604800']);
_paq.push(['setSessionCookieTimeout', '0']);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
var d=document,
g=d.createElement('script'),
s=d.getElementsByTagName('script')[0];
g.type='text/javascript';
g.defer=true;
g.async=true;
g.src=u+'piwik.js';
s.parentNode.insertBefore(g,s);
})();
}
<!-- End Piwik Code -->
Ofcourse there is an opt out code provided by piwik and it could be customized and inserted into an iframe. I will try this next, but an if statement should also work.

Comments

Sign In or Register to comment.

So You Wanna Be An eLearning ROCKSTAR?

We're all fans of eLearning here! Want to become an eLearning ROCKSTAR? Just click on one of the buttons below to start your rocking journey!