Jump to content

PayPal Pro not tracking ADWORDS conversion code


Supermanzo

Recommended Posts

Hello,

i'm facing this problem: Since when i started using paypal pro solution in an iframe embedded in the payment page i always had the same problem: most of the payments done in the iframe are not tracked by adwords. I'm assuming after many tests that customers after the confirmation inside the iframe are not redirected on the standard prestashop redirect page, and they just go on another page or close the browser. This is a huge issue because most of the payments are credit card and so i lose track of most of the data i need.
Is there anyone who has faced the same problem and came up with a solution?

I thought about using the return url, for the confirmation inside paypal settings. Is it possible? Any advice on how to set this in a multilanguage environment ?

 

Thanks in Advance

Link to comment
Share on other sites

  • 11 months 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. Ensure you have the Prestashop Google Analytics Module installed (my version was - Version : 1.8.1)
  2. Now Find the following file: /modules/ganalytics/views/templates/hook/header.tpl
  3. Open the header.tpl file in your preferred editor (see appendix 1 below for a view of my file before it was edited)
  4. Login to your adwords account and generate your custom conversion tracking code.
  5. Paste your Adwords conversion code at the bottom below the closing analytics script tag. (See my example - appendix 2)
  6. Change this parameter within your adwords conversion tracking code: var google_conversion_value = {$trans.total};
  7. Save and push the file live
  8. Do a test transaction to make sure you haven't made a fatal error
  9. Watch the data appear in your adwords account (It takes about an hour from when your first order was placed.

Hope that helps (Please note: im a bodger, not a developer)

 

 

Appendix 1

 

{*
* 2007-2014 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <[email protected]>
*  @copyright  2007-2014 PrestaShop SA
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*}
<script type="text/javascript">
    {if $universal_analytics eq true}
    {literal}
    (function (i, s, o, g, r, a, m) {
        i['GoogleAnalyticsObject'] = r;
        i[r] = i[r] || function () {
            (i[r].q = i[r].q || []).push(arguments)
        }, i[r].l = 1 * new Date();
        a = s.createElement(o),
                m = s.getElementsByTagName(o)[0];
        a.async = 1;
        a.src = g;
        m.parentNode.insertBefore(a, m)
    })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
    {/literal}

    ga('create', '{$ganalytics_id|escape:'htmlall':'UTF-8'}'{if isset($pageTrack)}, '{$pageTrack|escape:'htmlall':'UTF-8'}'{/if});

    {if $isOrder eq true}
    ga('require', 'ecommerce', 'ecommerce.js');
    {else}
    ga('send', 'pageview');
    {/if}

    {if $isOrder eq true}
    ga('ecommerce:addTransaction', {
        'id': '{$trans.id|escape:'htmlall':'UTF-8'}',
        'affiliation': '{$trans.store|escape:'htmlall':'UTF-8'}',
        'revenue': '{$trans.total|escape:'htmlall':'UTF-8'}',
        'tax': '{$trans.tax|escape:'htmlall':'UTF-8'}',
        'shipping': '{$trans.shipping|escape:'htmlall':'UTF-8'}',
        'city': '{$trans.city|escape:'htmlall':'UTF-8'}',
        'state': '{$trans.state|escape:'htmlall':'UTF-8'}',
        'country': '{$trans.country|escape:'htmlall':'UTF-8'}',
        'currency': '{$trans.currency|escape:'htmlall':'UTF-8'}'
    });

    {foreach from=$items item=item}
    ga('ecommerce:addItem', {
        'id': '{$item.OrderId|escape:'htmlall':'UTF-8'}',
        'sku': '{$item.SKU|escape:'htmlall':'UTF-8'}',
        'name': '{$item.Product|escape:'htmlall':'UTF-8'}',
        'category': '{$item.Category|escape:'htmlall':'UTF-8'}',
        'price': '{$item.Price|escape:'htmlall':'UTF-8'}',
        'quantity': '{$item.Quantity|escape:'htmlall':'UTF-8'}'
    });
    {/foreach}
    {literal}
    (function() {
        {/literal}{if $isOrder eq true}{literal}
            var key = 'ga_trans';
            var idtrans = {/literal}{$trans.id|intval}{literal};
            if (!!$.prototype.totalStorage)
                var view_ga_trans = parseInt($.totalStorage(key));
            else if (typeof localStorage !== 'undefined' && localStorage)
                var view_ga_trans = parseInt(localStorage.getItem(key));

            if (typeof view_ga_trans !== 'undefined' &&  view_ga_trans > 0 && idtrans == view_ga_trans )
                return false;

            if (!!$.prototype.totalStorage)
                $.totalStorage(parseInt(key, idtrans));
            else if (typeof localStorage !== 'undefined' && localStorage)
                localStorage.setItem(key, parseInt(idtrans));
        {/literal}{/if}{literal}
        ga('ecommerce:send');
    })();
    {/literal}
    {/if}
    {else}
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', '{$ganalytics_id|escape:'htmlall':'UTF-8'}']);
    // Recommended value by Google doc and has to before the trackPageView
    _gaq.push(['_setSiteSpeedSampleRate', 5]);

    _gaq.push(['_trackPageview'{if isset($pageTrack)}, '{$pageTrack|escape:'htmlall':'UTF-8'}'{/if}]);

    {if $isOrder eq true}            {* If it's an order we need more data for stats *}
    _gaq.push(['_addTrans',
        '{$trans.id|escape:'htmlall':'UTF-8'}', {* order ID - required *}
        '{$trans.store|escape:'htmlall':'UTF-8'}', {* affiliation or store name *}
        '{$trans.total|escape:'htmlall':'UTF-8'}', {* total - required *}
        '{$trans.tax|escape:'htmlall':'UTF-8'}', {* tax *}
        '{$trans.shipping|escape:'htmlall':'UTF-8'}', {* shipping *}
        '{$trans.city|escape:'htmlall':'UTF-8'}', {* city *}
        '{$trans.state|escape:'htmlall':'UTF-8'}', {* state or province *}
        '{$trans.country|escape:'htmlall':'UTF-8'}' {* country *}
    ]);

    {foreach from=$items item=item}
    _gaq.push(['_addItem',
        '{$item.OrderId|escape:'htmlall':'UTF-8'}', {* order ID - required *}
        '{$item.SKU|escape:'htmlall':'UTF-8'}', {* SKU/code - required *}
        '{$item.Product|escape:'htmlall':'UTF-8'}', {* product name *}
        '{$item.Category|escape:'htmlall':'UTF-8'}', {* category or variation *}
        '{$item.Price|escape:'htmlall':'UTF-8'}', {* unit price - required *}
        '{$item.Quantity|escape:'htmlall':'UTF-8'}' {* quantity - required *}
    ]);
    {/foreach}
    {* submits transaction to the Analytics servers *}
    {literal}
    _gaq.push(['_trackTrans']);
    {/literal}
    {/if}
    {literal}
    (function() {
        {/literal}{if $isOrder eq true}{literal}
            var key = 'ga_trans';
            var idtrans = {/literal}{$trans.id|intval}{literal};
            if (!!$.prototype.totalStorage)
                var view_ga_trans = parseInt($.totalStorage(key));
            else if (typeof localStorage !== 'undefined' && localStorage)
                var view_ga_trans = parseInt(localStorage.getItem(key));

            if (typeof view_ga_trans !== 'undefined' &&  view_ga_trans > 0 && idtrans == view_ga_trans )
                return false;

            if (!!$.prototype.totalStorage)
                $.totalStorage(parseInt(key, idtrans));
            else if (typeof localStorage !== 'undefined' && localStorage)
                localStorage.setItem(key, parseInt(idtrans));
        {/literal}{/if}{literal}

        var ga = document.createElement('script');
        ga.type = 'text/javascript';
        ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0];
        s.parentNode.insertBefore(ga, s);
    })();
    {/literal}
    {/if}
</script>

 

 

 

 

Appendix 2: (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 = {$trans.total};
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 -->
 

Link to comment
Share on other sites

  • 1 year later...

You need to put your conversion tracking before the payment.

If you want absolutly to put your conversion tacking after the order (when customer make purchase) you need to put the conversion tracking inside the validate Paypal page (in the paypal module)

Make a test

Edited by Deasy-Oak (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...