Dynamic Remarketing

[quote name='mazter' timestamp='1410511462' post='192103']

eComLabs, that was great help, thank you for the assistance. Looks like with the newest CSCart version,



[color=#008800]/*




is being replaced as





//


This is preventing Google to recognize their code on the website. What is the best way to be able to include the code to show on the wewbsite “as is” ?



Thank you

[/quote]



Please take a look:



Adapt Your Add-Ons To CS-Cart 4.2.1 - Developers' Corner - CS-Cart Community Forums


[quote]We have completely switched to HTML5. There is no more need in the following structure in JavaScript code:



// ...
//]]>

[/quote]



Just remove it.

[quote name=‘eComLabs’ timestamp=‘1406531672’ post=‘188312’]

Try this code:


<br />
{if $controller eq 'checkout' && $mode ne 'complete'}<br />
{capture name="cart_order_info"}<br />
{foreach from=$cart_products item="item" name="products"}<br />
'{$item.product_code}'{if not $smarty.foreach.products.last},{/if}<br />
{/foreach}<br />
{/capture}<br />
{/if}<br />
<br />
{if $controller eq 'checkout' && $mode eq 'complete'}<br />
{capture name="checkout_order_info"}<br />
{foreach from=$order_info.items item="item" name="products"}<br />
'{$item.product_code}'{if not $smarty.foreach.products.last},{/if}<br />
{/foreach}<br />
{/capture}<br />
{/if}<br />
<br />
{literal}<br />
<!-- Google Code for Remarketing Tag --><br />
<!--------------------------------------------------<br />
Remarketing tags may not be associated with personally identifiable information or placed on pages related to sensitive categories. See more information and instructions on how to setup the tag on: http://google.com/ads/remarketingsetup<br />
---------------------------------------------------><br />
<br />
<script type="text/javascript"><br />
var google_tag_params = {<br />
ecomm_prodid: {/literal}{if $controller eq 'products'}'{$product.product_code}',{elseif $controller eq 'checkout' && $mode ne 'complete'}[{$smarty.capture.cart_order_info}],{elseif $controller eq 'checkout' && $mode eq 'complete'}[{$smarty.capture.checkout_order_info}],{else}'',{/if}{literal}<br />
<br />
ecomm_pagetype: '{/literal}{if $controller eq 'index'}home{elseif $controller eq 'categories'}category{elseif $controller eq 'products'}product{elseif $controller eq 'checkout' && $mode eq 'complete'}purchase{elseif $controller eq 'checkout' && $mode ne 'complete'}cart{else}siteview{/if}{literal}',<br />
ecomm_totalvalue: '{/literal}{if $controller eq 'products'}{$product.price|number_format:2}{elseif $controller eq 'checkout' && $mode eq 'complete'}{$order_info.subtotal|number_format:2}{elseif $controller eq 'checkout' && $mode ne 'complete'}{$cart.subtotal|number_format:2}{/if}{literal}',<br />
};<br />
</script><br />
<br />
<script type="text/javascript"><br />
/* <![CDATA[ */<br />
var google_conversion_id = XXXXXXXXXXX;<br />
var google_custom_params = window.google_tag_params;<br />
var google_remarketing_only = true;<br />
/* ]]> */<br />
</script><br />
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js"><br />
</script><br />
<noscript><br />
<div style="display:inline;"><br />
<img height="1" width="1" style="border-style:none;" alt="" src="upload://ux1zSLp9vBY9KEUw7CSvZVrESee.gif"><br />
</div><br />
</noscript><br />
{/literal}<br />

```<br />
[/quote]<br />
<br />
Ecom labs where do we need to paste this code ? Do we need to create a my_changes file for this ? Or somewhere else.

That code is for 3.0.x versions (!)



You can add it to the following file:



skins\basic\customer\addons\my_changes\hooks\checkout\order_confirmation.post.tpl

[quote name=‘eComLabs’ timestamp=‘1435151955’ post=‘220205’]

That code is for 3.0.x versions (!)



You can add it to the following file:



skins\basic\customer\addons\my_changes\hooks\checkout\order_confirmation.post.tpl

[/quote]



I cant find this path it seems its of some old version, do you mean to say this path

<br />
\design\themes\vivashop\templates\addons\my_changes\hooks\checkout\order_confirmation.post.tpl<br />

```<br />
<br />
Also is the code below correct for MVE 4.2.4 since the output i get is<br />
```php
<br />
{if $controller eq 'checkout' && $mode ne 'complete'}<br />
{capture name="cart_order_info"}<br />
{foreach from=$cart_products item="item" name="products"}<br />
'{$item.product_code}'{if not $smarty.foreach.products.last},{/if}<br />
{/foreach}<br />
{/capture}<br />
{/if}<br />
{if $controller eq 'checkout' && $mode eq 'complete'}<br />
{capture name="checkout_order_info"}<br />
{foreach from=$order_info.products  item="item" name="products"}<br />
'{$item.product_code}'{if not $smarty.foreach.products.last},{/if}<br />
{/foreach}<br />
{/capture}<br />
{/if}<br />
{literal}<br />
<!-- Google Code for Remarketing Tag --><br />
<!--------------------------------------------------<br />
Remarketing tags may not be associated with personally identifiable information or placed on pages related to sensitive categories. See more information and instructions on how to setup the tag on: http://google.com/ads/remarketingsetup<br />
---------------------------------------------------><br />
<script type="text/javascript"><br />
var google_tag_params = {<br />
ecomm_prodid: {/literal}{if $controller eq 'products'}'{$product.product_code}',{elseif $controller eq 'checkout' && $mode ne 'complete'}[{$smarty.capture.cart_order_info}],{elseif $controller eq 'checkout' && $mode eq 'complete'}[{$smarty.capture.checkout_order_info}],{else}'',{/if}{literal}<br />
ecomm_pagetype: '{/literal}{if $controller eq 'index'}home{elseif $controller eq 'categories'}category{elseif $controller eq 'products'}product{elseif $controller eq 'checkout' && $mode eq 'complete'}purchase{elseif $controller eq 'checkout' && $mode ne 'complete'}cart{else}siteview{/if}{literal}',<br />
ecomm_totalvalue: '{/literal}{if $controller eq 'products'}{$product.price|number_format:2}{elseif $controller eq 'checkout' && $mode eq 'complete'}{$order_info.subtotal|number_format:2}{elseif $controller eq 'checkout' && $mode ne 'complete'}{$cart.subtotal|number_format:2}{/if}{literal}',<br />
};<br />
</script><br />
<script type="text/javascript"><br />
/* <![CDATA[ */<br />
var google_conversion_id = xxxxxxx;<br />
var google_custom_params = window.google_tag_params;<br />
var google_remarketing_only = true;<br />
/* ]]> */<br />
</script><br />
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js"><br />
</script><br />
<noscript><br />
<div style="display:inline;"><br />
<img height="1" width="1" style="border-style:none;" alt="" src="upload://ux1zSLp9vBY9KEUw7CSvZVrESee.gif"><br />
</div><br />
</noscript><br />
{/literal}<br />

```<br />
<br />
<br />
Output is<br />
<br />
```php
<br />
<script type="text/javascript">var google_tag_params={ecomm_prodid:'',ecomm_pagetype:'siteview',ecomm_totalvalue:'',};</script><br />

```<br />
Also i have a query that :[list=1]<br />
[*]if we are posting this code on checkout page only then how will the google track the products which a customer:<br />
[list]<br />
[*]has viewed.<br />
[*]added to cart but dint checkout.<br />
[*]checked out but dint pay<br />
[*]added to wishlist.<br />
[/list]	<br />
[/list]<br />
	<br />
<br />
Does this make sense.[list]<br />
[*]Wouldn't this code be required on Product page / Cart/  Checkout / Wishlist page as well to track that information so that google can remarket that product to the customer.<br />
[*]Is order_confirmation.post.tpl the right place to post this code or some better way exists to cover all above scenarios.<br />
[/list]

[color=#282828][font=arial, verdana, tahoma, sans-serif]In the latest versions you should use [/font][/color]$order_info.products[color=#282828][font=arial, verdana, tahoma, sans-serif] instead of the [/font][/color]$order_info.items[color=#282828][font=arial, verdana, tahoma, sans-serif] . Please try. [/font][/color]

[quote name='eComLabs' timestamp='1435224716' post='220313']

[color=#282828][font=arial, verdana, tahoma, sans-serif]In the latest versions you should use [/font][/color]$order_info.products[color=#282828][font=arial, verdana, tahoma, sans-serif] instead of the [/font][/color]$order_info.items[color=#282828][font=arial, verdana, tahoma, sans-serif] . Please try. [/font][/color]

[/quote]

I am using the same only.

Please also try:



$runtime.controller and $runtime.mode



instead of



$controller and $mode



Note that this code will output totals on the checkout and order landing pages only.

[quote name='eComLabs' timestamp='1435327416' post='220554']

Please also try:



$runtime.controller and $runtime.mode



instead of



$controller and $mode



Note that this code will output totals on the checkout and order landing pages only.

[/quote]



Thanks Ecom labs it works , you are awesome, cant thank you enough for all the help you provide.



Just one more thing how do i track the same info for the cases below when customer:

[list]

[]added product to cart but dint checkout.

[
]checked out but dint pay

[*]added to wishlist.

[/list]

[color=#282828][font=arial, verdana, tahoma, sans-serif]Just one more thing how do i track the same info for the cases below when customer:[/font][/color][list]

[]added product to cart but dint checkout.

[
]checked out but dint pay

[*]added to wishlist.

[/list]

I am afraid, these features are not supported by the remarketing code. It is required to integrate additional services. E.g.:

Can anyone try and add this addon in v.4? How can we do?

Can anyone try and add this addon in v.4? How can we do?

We can perform integration within the separate task for you. Feel free to contact us

buy the addon from simtech for this purpose.

{if $runtime.controller eq 'checkout' && $runtime.mode ne 'complete'}

{capture name="cart_order_info"}

{foreach from=$cart_products item="item" name="products"}

'{$item.product_code}'{if not $smarty.foreach.products.last},{/if}

{/foreach}

{/capture}

{/if}



{if $runtime.controller eq 'checkout' && $runtime.mode eq 'complete'}

{capture name="checkout_order_info"}

{foreach from=$order_info.products item="item" name="products"}

'{$item.product_code}'{if not $smarty.foreach.products.last},{/if}

{/foreach}

{/capture}

{/if}



{literal}











{/literal}

I 'm using this code and everything looks fine but gives me an error at Tag assistant :

google_tag_params

{
"dynx_itemid": "abcgfr543",
"dynx_pagetype": "offerdetail",
"dynx_totalvalue": "896.00"
}

Number field should not be quoted: 'dynx_totalvalue'

Any ideas?

Looks like this

dynx_totalvalue: '{/literal}{if $runtime.controller eq 'products'}{$product.price|number_format:2}{elseif $runtime.controller eq 'checkout' && $runtime.mode eq 'complete'}{$order_info.subtotal|number_format:2}{elseif $runtime.controller eq 'checkout' && $runtime.mode ne 'complete'}{$cart.subtotal|number_format:2}{/if}{literal}',

should be replaced with

dynx_totalvalue: {/literal}{if $runtime.controller eq 'products'}{$product.price|number_format:2}{elseif $runtime.controller eq 'checkout' && $runtime.mode eq 'complete'}{$order_info.subtotal|number_format:2}{elseif $runtime.controller eq 'checkout' && $runtime.mode ne 'complete'}{$cart.subtotal|number_format:2}{else}0{/if}{literal},

Looks like this

dynx_totalvalue: '{/literal}{if $runtime.controller eq 'products'}{$product.price|number_format:2}{elseif $runtime.controller eq 'checkout' && $runtime.mode eq 'complete'}{$order_info.subtotal|number_format:2}{elseif $runtime.controller eq 'checkout' && $runtime.mode ne 'complete'}{$cart.subtotal|number_format:2}{/if}{literal}',

should be replaced with

dynx_totalvalue: {/literal}{if $runtime.controller eq 'products'}{$product.price|number_format:2}{elseif $runtime.controller eq 'checkout' && $runtime.mode eq 'complete'}{$order_info.subtotal|number_format:2}{elseif $runtime.controller eq 'checkout' && $runtime.mode ne 'complete'}{$cart.subtotal|number_format:2}{else}0{/if}{literal},

Thank you very very much. Works great. No error appears now but does not keep decimal under 1000. Don't think can be a problem

how can i select product_id and not product_code (merchant center request product_id not sku products)?

Use

{$product.product_id}

instead of

{$product.product_code}

Use

{$product.product_id}

instead of

{$product.product_code}

Show always sku and not product id.

Show always sku and not product id.

Do not forget to clear cache