Jump to content

Google Adwords conversion tracking


Recommended Posts

Any one know how to add conversion tracking to prestashop

 

what file and where in the file should i paste the google code ??

 

tryed order_confermation.php but that just broke all the accept order requists

 

help plz

Link to comment
Share on other sites

  • 3 months later...
  • 5 months later...
  • 1 month later...

Just in case anyone is still needing this enhancement i.e. Conversion Tracking for Google AdWords, see the attached.

It is a modified version of the the Google Analytics module... (sorry was lazy to rewrite it as a new module) :D

All you need to do is save (overwrite) this file in the

your_prestashop_root/modules/ganalytics/
directory.

You need to set-up an Action in the Conversion Tracking menu on Google Analytics. You will need two elements from the script - look for these lines and copy the values (here marked with NNNNN) and paste in the module configuration form:
var google_conversion_id = NNNNNNNNNNN; // the number (here marked with NNNNNN) 
                                   // needs to go in the Conversion ID field
..
var google_conversion_label = "NNNNNNNNN"; // the string (here marked with NNNNNNN) 
                                    // needs to go in the Conversion Label field



The enhancement will tell Google the total price of the purchase (once they complete the purchase the code will be activated)

This module has been tested on PrestaShop v1.1 with English language (although the enhancement is ready for other languages, I have not translated...)

Hope this is helpful!
Vlad

ganalytics.php

Link to comment
Share on other sites

  • 5 weeks later...

Just updated the file above with a new hook - the original code had a problem tracking PayPal conversion as paypal module never confrims the order, unless the customer clicks on the "return to merchant" button...
Just testing at the moment, will be able to tell shortly.

And the result is negative... as for GA conversion etc tracking to work, the code needs to be rendered in browser, so, I am stuck... :down:

Vlad

Link to comment
Share on other sites

  • 2 months later...

Hi, it works but only on cheques
probably because the hooking orderconfirmation is not visible with online payments, like atos.

I put it in the page just before the payment , quick'n dirty:

ganalytics.php, change the modified end with

           $output .= '
             pageTracker._trackTrans();
           [removed]';
           $output .= GAnalytics::get_conversion_code();
           return $output;
       }
   }
   static function get_conversion_code()
   {
       if (!Configuration::get('ADWORDS_CODE')) return '';
       return('
           [removed]
           <!--
           var google_conversion_id = '.Configuration::get('ADWORDS_CODE').';
           var google_conversion_language = "fr";
           var google_conversion_format = "3";
           var google_conversion_color = "ffffff";
           var google_conversion_label = "'.Configuration::get('ADWORDS_LABEL').'";
           //-->
           [removed]
           [removed]
           [removed]



           ');
   }
}
?>



in the ugly atos pre-payment page code
module/atos/call_request.php

       } else {
           if (file_exists(dirname(__FILE__).'/../ganalytics/ganalytics.php'))
           {
               include(dirname(__FILE__).'/../ganalytics/ganalytics.php');
               print GAnalytics::get_conversion_code();
           }
           print ("Paiement par Carte Bancaire.
");
           print ("
Régler votre achat d'un montant total de $amount € par carte bancaire.

");
           print (" ".str_replace('SSL, ','SSL,
',$message)." 
");



actually, it is not the real prestashop's atos implementation,
it is modatospresta , https://sourceforge.net/projects/modatospresta/
I hope in the official one the hook is visible and possible

Link to comment
Share on other sites

  • 1 month later...
Just in case anyone is still needing this enhancement i.e. Conversion Tracking for Google AdWords, see the attached.

It is a modified version of the the Google Analytics module... (sorry was lazy to rewrite it as a new module) :D

All you need to do is save (overwrite) this file in the
your_prestashop_root/modules/ganalytics/
directory.

You need to set-up an Action in the Conversion Tracking menu on Google Analytics. You will need two elements from the script - look for these lines and copy the values (here marked with NNNNN) and paste in the module configuration form:
var google_conversion_id = NNNNNNNNNNN; // the number (here marked with NNNNNN) 
                                   // needs to go in the Conversion ID field
..
var google_conversion_label = "NNNNNNNNN"; // the string (here marked with NNNNNNN) 
                                    // needs to go in the Conversion Label field



The enhancement will tell Google the total price of the purchase (once they complete the purchase the code will be activated)

This module has been tested on PrestaShop v1.1 with English language (although the enhancement is ready for other languages, I have not translated...)

Hope this is helpful!
Vlad



Thanks
Link to comment
Share on other sites

  • 1 month later...
  • 1 year later...
  • 1 year later...
  • 1 year later...
  • 2 years later...

Hi,

 

Did you get this sorted in the end, if not below is how I managed to get it to work (its a bit of a bodge job but it was very easy and worked a treat on my PrestaShop™ 1.5.2.0)

  1. Open your theme order confirmation file: /themes/your-theme/order-confirmation.tpl
  2. Login to your adwords account and generate your custom conversion tracking code.
  3. Paste your Adwords conversion code at the bottom below the last /if tag.
  4. Change this parameter within your adwords conversion tracking code: var google_conversion_value = <literal>{$trans.total};</literal>
  5. Save and push the file live
  6. Do a test transaction to make sure you haven't made a fatal error
  7. Watch the data appear in your adwords account (It takes about an hour from when your first order was placed.

Hope that helps

 

 

(My adwords code with my ID's removed)

<!-- START Google Code for Order Conf Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = YOUR-ID-HERE;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "YOUR-LABEL-HERE";
var google_conversion_value = <literal>{$trans.total};</literal>
var google_conversion_currency = "GBP";
var google_remarketing_only = false;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/YOURVALUE/?value=0.00&currency_code=GBP&label=YOURLABEL&guid=ON&script=0"/>
</div>
</noscript>
<!-- END Google Adwords Code for Order Conf Conversion Page -->
 

Edited by nematodesdirect (see edit history)
Link to comment
Share on other sites

  • 1 year later...

Hello,

 

I'm searching for a solution for about half a year now and I really don't know how to make this google adwords conversion tracking implementation working. I have pasted my codes in public_html->my-theme->order-confirmation.tpl.

 

This is my code:

 

{/if}

 
<!-- Google Code for (...) Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
{assign var='id_cart' value={$request_uri|regex_replace:"/.*id_cart=([\d]*).*/":"$1"[spam-filter]
{assign var='total_cart' value={$cart->getTotalCart($id_cart)|regex_replace:"/[\D]+.*/":""[spam-filter]
{literal}
var google_conversion_id = 123456789;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "my label";
var google_remarketing_only = false;
var google_conversion_value = {/literal}{$total_cart}{literal};{/literal}
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/928385315/?label=8MnhCJ7pt2gQo5LYugM&guid=ON&script=0"/>
</div>
</noscript>
 
 
This is what google tag assistant says: 
 
- Conversion value should be prefixed with standard currency. (so it has to be €)
- Missing line breaks may cause issues
- Code should be placed directly above the closing <body> tag
 
I don't know how to fix this. Can anyone help me? 
Thank you in advance!
Link to comment
Share on other sites

 

Hello,

 

I'm searching for a solution for about half a year now and I really don't know how to make this google adwords conversion tracking implementation working. I have pasted my codes in public_html->my-theme->order-confirmation.tpl.

 

This is my code:

 

{/if}

 
<!-- Google Code for (...) Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
{assign var='id_cart' value={$request_uri|regex_replace:"/.*id_cart=([\d]*).*/":"$1"[spam-filter]
{assign var='total_cart' value={$cart->getTotalCart($id_cart)|regex_replace:"/[\D]+.*/":""[spam-filter]
{literal}
var google_conversion_id = 123456789;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "my label";
var google_remarketing_only = false;
var google_conversion_value = {/literal}{$total_cart}{literal};{/literal}
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/928385315/?label=8MnhCJ7pt2gQo5LYugM&guid=ON&script=0"/>
</div>
</noscript>
 
 
This is what google tag assistant says: 
 
- Conversion value should be prefixed with standard currency. (so it has to be €)
- Missing line breaks may cause issues
- Code should be placed directly above the closing <body> tag
 
I don't know how to fix this. Can anyone help me? 
Thank you in advance!

 

 

Hi,

 

I've just updated the code in the example above, try that - don't forget to change your currency to EUR

 

:-)

Link to comment
Share on other sites

  • 4 weeks later...

 

Hello,

 

I'm searching for a solution for about half a year now and I really don't know how to make this google adwords conversion tracking implementation working. I have pasted my codes in public_html->my-theme->order-confirmation.tpl.

 

This is my code:

 

{/if}

 
<!-- Google Code for (...) Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
{assign var='id_cart' value={$request_uri|regex_replace:"/.*id_cart=([\d]*).*/":"$1"[spam-filter]
{assign var='total_cart' value={$cart->getTotalCart($id_cart)|regex_replace:"/[\D]+.*/":""[spam-filter]
{literal}
var google_conversion_id = 123456789;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "my label";
var google_remarketing_only = false;
var google_conversion_value = {/literal}{$total_cart}{literal};{/literal}
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/928385315/?label=8MnhCJ7pt2gQo5LYugM&guid=ON&script=0"/>
</div>
</noscript>
 
 
This is what google tag assistant says: 
 
- Conversion value should be prefixed with standard currency. (so it has to be €)
- Missing line breaks may cause issues
- Code should be placed directly above the closing <body> tag
 
I don't know how to fix this. Can anyone help me? 
Thank you in advance!

 

Hey,

 

Did you find a solution ?

Link to comment
Share on other sites

  • 3 months later...
×
×
  • Create New...