Kod konwersji e-commerce prestashop 1.6. gdzie dodać

https://www.prestashop.com/forums/topic/253582-google-adwords-conversion-tracking-code-placement/page-2

Why did you set up google_conversion_value to 0 ?

Google’s suggested php implementation looks like this:

<!-- Kod Google na stronę konwersji zakupowej -->
	 type="text/javascript">
	/* 
	var google_conversion_id = 1234567890;
	var google_conversion_language = "pl_PL";
	var google_conversion_format = "1";
	var google_conversion_color = "666666";
	var google_conversion_label = "xxx-XXx1xXXX123X1xX";
	var google_conversion_value = 10;                                 //strike through!
	if ( echo $totalValue ?>) {                                     //bold!
		var google_conversion_value =  echo $totalValue ?>      //bold!
		var google_conversion_currency =  echo $currency ?>     //bold!
	}                                                                 //bold!
	var google_conversion_currency = "PLN";                           //strike through!
	/* ]]> */ 
	
	 type="text/javascript"
	src="//www.googleadservices.com/pagead/conversion.js">
	
	<noscript>
	<img height=1 width=1 border=0
	src="//www.googleadservices.com/pagead/
	conversion/1234567890/?value=
	<? echo $totalValue ?>&conversion_currency=<? echo $currency ?>
	&label=Zakup&script=0">
	</noscript>
	</body>

but everyone should base on code given to them by google adwords, and then cut out lines which are struck through, and implement proper variables in places which are bold.

EDIT: Sorry, I realised that strike-through and bold formatting doesn’t work inside code field. It is hard to repair this, so i commented lines :<<

 

On prestashop 1.6 modifications should look like this (for example; works for me):

 

1. In controllers/front/OrderConfirmationController find:

public function initContent()
	{
		parent::initContent();

		$this->context->smarty->assign(array(
			'is_guest' => $this->context->customer->is_guest,
			'HOOK_ORDER_CONFIRMATION' => $this->displayOrderConfirmation(),
			'HOOK_PAYMENT_RETURN' => $this->displayPaymentReturn()
		));

and change to:

public function initContent()
	{
		parent::initContent();

        $order = new Order($this->id_order);
        $currency = new Currency($order->id_currency);

		$this->context->smarty->assign(array(
			'is_guest' => $this->context->customer->is_guest,
			'HOOK_ORDER_CONFIRMATION' => $this->displayOrderConfirmation(),
			'HOOK_PAYMENT_RETURN' => $this->displayPaymentReturn(),
                        'name_of_cart_value_variable' => $order->getOrdersTotalPaid(),   // name_of_cart_value_variable
                        'name_of_currency_variable' => $currency->sign                   // name_of_currency_variable
		));

2. Then navigate to themes/YOUR_THEME/order-confirmation.tpl, and after the last {/if} add:

 type="text/javascript">
    /* 
    {literal}
    var google_conversion_id = 1234567890;     //your conversion id given by google!
    var google_conversion_language = "pl_PL";  //for example. You could put your language sign, or create another variable responsible for this.
    var google_conversion_format = "1";        //for example
    var google_conversion_color = "666666";    //example as well
    var google_conversion_label = "xxx-XXx1xXXX123X1xX"; //your label given by google!
    if ( {/literal}{$name_of_cart_value_variable}{literal} ) {
        var google_conversion_value =  "{/literal}{$name_of_cart_value_variable}{literal}"
        var google_conversion_currency =  "{/literal}{$name_of_currency_variable}{literal}"
    }                                          //careful in above lines 
    var google_remarketing_only = false;       //for example
    {/literal}
    /* ]]> */

 type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">

<noscript>
    
style=display:inline;> height=„1” width=„1” style=borderstyle:none; alt=„” src=„//www.googleadservices.com/pagead/conversion/953948678/?value={$name_of_cart_value_variable}&conversion_currency={$name_of_currency_variable}&label=Zakup&script=0”/> //the last two variables here

 


</noscript>

You could customize other values send to google adwords, then you should retrieve them in controller. You got the vibe.

 

EDIT: Sorry for poor formatting, it’s hard to get rid of code blocks once they had been added.

Advertisements

Skomentuj

Wprowadź swoje dane lub kliknij jedną z tych ikon, aby się zalogować:

Logo WordPress.com

Komentujesz korzystając z konta WordPress.com. Log Out / Zmień )

Zdjęcie z Twittera

Komentujesz korzystając z konta Twitter. Log Out / Zmień )

Facebook photo

Komentujesz korzystając z konta Facebook. Log Out / Zmień )

Google+ photo

Komentujesz korzystając z konta Google+. Log Out / Zmień )

Connecting to %s