Adding Website optimizer javascript into PHP variable
$30-250 USD
已完成
已发布将近 13 年前
$30-250 USD
货到付款
Hi,
I like to include a javascript of Google website optimer into a PHP variable which i like to assign with smarty to a template. Here i send you the example code:
$optimizer_test = <!-- Google Website Optimizer Control Script -->
<script>
function utmx_section(){}function utmx(){}
(function(){var k='0231920119',d=document,l=[login to view URL],c=[login to view URL];function f(n){
if(c){var i=[login to view URL](n+'=');if(i>-1){var j=[login to view URL](';',i);return escape([login to view URL](i+n.
length+1,j<0?[login to view URL]:j))}}}var x=f('__utmx'),xx=f('__utmxx'),h=[login to view URL];
[login to view URL]('<sc'+'ript src="'+
'http'+(l.protocol=='https:'?'s://ssl':'://www')+'.[login to view URL]'
+'/[login to view URL]'+k+'&utmx='+(x?x:'')+'&utmxx='+(xx?xx:'')+'&utmxtime='
+new Date().valueOf()+(h?'&utmxhash='+escape([login to view URL](1)):'')+
'" type="text/javascript" charset="utf-8"></sc'+'ript>')})();
</script>
<!-- End of Google Website Optimizer Control Script -->
<!-- Google Website Optimizer Tracking Script -->
<script type="text/javascript">
var _gaq = _gaq || [];
[login to view URL](['gwo._setAccount', 'UA-3927776-2']);
[login to view URL](['gwo._trackPageview', '/0231920119/test']);
(function() {
var ga = [login to view URL]('script'); [login to view URL] = 'text/javascript'; [login to view URL] = true;
[login to view URL] = ('https:' == [login to view URL] ? 'https://ssl' : 'http://www') + '.[login to view URL]';
var s = [login to view URL]('script')[0]; [login to view URL](ga, s);
})();
</script>
<!-- End of Google Website Optimizer Tracking Script -->
Then assign to smarty:
$smarty->assign('optimizer_test', $optimizer_test);
Then read it in the smarty template:
{dynamic}{$optimizer_test}{/dynamic}
I als want to do this with the conversion script of google website optimizer:
<!-- Google Website Optimizer Tracking Script -->
<script type="text/javascript">
var _gaq = _gaq || [];
[login to view URL](['gwo._setAccount', 'UA-3927776-2']);
[login to view URL](['gwo._trackPageview', '/0231920119/goal']);
(function() {
var ga = [login to view URL]('script'); [login to view URL] = 'text/javascript'; [login to view URL] = true;
[login to view URL] = ('https:' == [login to view URL] ? 'https://ssl' : 'http://www') + '.[login to view URL]';
var s = [login to view URL]('script')[0]; [login to view URL](ga, s);
})();
</script>
<!-- End of Google Website Optimizer Tracking Script -->
But when i use this code i get the follwing error:
Parse error: syntax error, unexpected '<'
Could you please help fixing this.