Jump to content

[v1.6.1.17] Any idea how to add Google Survey code to Prestashop?


Nando@100ASA

Recommended Posts

Hello there.

Could someone help me adding the google survey code into the order confirmation page? here is the code that google wants i add into my prestashop build:

<!-- INIZIO Codice per la lingua di Recensioni dei clienti su Google -->
<script src="https://apis.google.com/js/platform.js?onload=renderOptIn"
  async defer>
</script>

<script>
  window.renderOptIn = function() { 
    window.gapi.load('surveyoptin', function() {
      window.gapi.surveyoptin.render(
        {
          "merchant_id": 42,
          "order_id": "<?php echo $order_id ?>",
          "email": "<?php echo $email_address ?>",
          "delivery_country": "<?php echo $user_country ?>",
          "estimated_delivery_date": "<?php echo $delivery_date ?>",
          "opt_in_style": "BOTTOM_LEFT_DIALOG"
        }); 
     });
  }
</script>
<!-- FINE Codice del modulo di attivazione sondaggio GCR -->

<!-- INIZIO Codice per la lingua di Recensioni dei clienti su Google -->
<script>
  window.___gcfg = {
    lang: 'en_US'
  };
</script>
<!-- FINE Codice per la lingua di Recensioni dei clienti su Google -->

Actually, it's pretty straightforward, so i'm adding it into my order-confirmation.tpl file. The problem is with the variables, to be honest i don't know the sintax i have to use to pass the values to the script and how to get them (I only know i'd need to alter the orderconfirmationcontroller first in order to get the variables, if they're not globals).

The main point is to recover, aside the merchant i already have, the $order_id, the $email_address, the $delivery_country and the $estimated_delivery_date variables, since it's the first time i'm doing this kind of operation.

Hope to get some help, thanks in advance guys!

ps: here is the reference page https://support.google.com/merchants/answer/7106244?hl=it&ref_topic=7105160&visit_id=1-636572167373570410-3175207081&rd=1

Edited by Nando@100ASA
title edit, additional info (see edit history)
Link to comment
Share on other sites

23 ore fa, Nishith dice:

Hi...

You need use  "hookOrderConfirmation" hook in you custom module php file
Read this topic

https://www.prestashop.com/forums/topic/34615-order-confirmation-hook-on-thank-you-page-for-google-analytics/

 

Thanks

That's pretty old, it's a 2009 thread, now we have a different version of PS, idk if it works... anyone could verify those info or update them for the new release?

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...