In Progress

Adding Website optimizer javascript into PHP variable

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=[url removed, login to view],c=[url removed, login to view];function f(n){

if(c){var i=[url removed, login to view](n+'=');if(i>-1){var j=[url removed, login to view](';',i);return escape([url removed, login to view](i+n.

length+1,j<0?[url removed, login to view]:j))}}}var x=f('__utmx'),xx=f('__utmxx'),h=[url removed, login to view];

[url removed, login to view]('<sc'+'ript src="'+

'http'+(l.protocol=='https:'?'s://ssl':'://www')+'.[url removed, login to view]'

+'/[url removed, login to view]'+k+'&utmx='+(x?x:'')+'&utmxx='+(xx?xx:'')+'&utmxtime='

+new Date().valueOf()+(h?'&utmxhash='+escape([url removed, login to view](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 || [];

[url removed, login to view](['gwo._setAccount', 'UA-3927776-2']);

[url removed, login to view](['gwo._trackPageview', '/0231920119/test']);

(function() {

var ga = [url removed, login to view]('script'); [url removed, login to view] = 'text/javascript'; [url removed, login to view] = true;

[url removed, login to view] = ('https:' == [url removed, login to view] ? 'https://ssl' : 'http://www') + '.[url removed, login to view]';

var s = [url removed, login to view]('script')[0]; [url removed, login to view](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 || [];

[url removed, login to view](['gwo._setAccount', 'UA-3927776-2']);

[url removed, login to view](['gwo._trackPageview', '/0231920119/goal']);

(function() {

var ga = [url removed, login to view]('script'); [url removed, login to view] = 'text/javascript'; [url removed, login to view] = true;

[url removed, login to view] = ('https:' == [url removed, login to view] ? 'https://ssl' : 'http://www') + '.[url removed, login to view]';

var s = [url removed, login to view]('script')[0]; [url removed, login to view](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.

Skills: Javascript, PHP, Smarty PHP

See more: php variable optimizer, smarty variable javascript, optimer, optimizer javascript php, substring c, get substring, get location javascript, c substring, smarty optimizer, smarty website optimizer, k google, conversion optimizer, h website, x js, tracking cookie, php error fixing, optimizer, javascript fixing, escape, async, async javascript code, tracking php code, javascript tracking, google javascript code, text hash

About the Employer:
( 24 reviews ) Leusden, Netherlands

Project ID: #1156225

Awarded to:

bcsaba

Think can do this for you!

$30 USD in 0 days
(29 Reviews)
4.6

2 freelancers are bidding on average $55 for this job

sidfishman

Please see PM, thanks.

$80 USD in 0 days
(70 Reviews)
6.3