Julia11
01-04-2012, 01:37 PM
Hi, i have 1 site with three different brands (three ID numbers). I have made a javascript if-statement but it doesnt work. Somebody see some wrong here, I think it should work properly. Thanks in advance ;) $language and $brand is set...
<script type="text/javascript">
var accountId;
var url;
if($language == 'test') {
if($brand = '1') {
accountId = 'UA-xxxxx-1'
url = '1.com'
} else if ($brand = '2') {
accountId = 'UA-xxxxx-2'
url = '2.com'
} else if ($brand = '3') {
accountId = 'UA-xxxxx-3'
url = '3.com'
}
var _gaq = _gaq || [];
_gaq.push(['_setAccount', accountId]);
_gaq.push(['_setDomainName', url]);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview', '/' + window.location.host + '/' + window.location.pathname]);
(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 type="text/javascript">
var accountId;
var url;
if($language == 'test') {
if($brand = '1') {
accountId = 'UA-xxxxx-1'
url = '1.com'
} else if ($brand = '2') {
accountId = 'UA-xxxxx-2'
url = '2.com'
} else if ($brand = '3') {
accountId = 'UA-xxxxx-3'
url = '3.com'
}
var _gaq = _gaq || [];
_gaq.push(['_setAccount', accountId]);
_gaq.push(['_setDomainName', url]);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview', '/' + window.location.host + '/' + window.location.pathname]);
(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>