Difference between revisions of "Setting up Yotpo Mail After Purchase"

From Spiffy Stores Knowledge Base

Line 27: Line 27:
 
To send order data to Yotpo, you'll need to generate a user token (UTOKEN).  Yotpo documentation on how to do this can be found at https://core-api.yotpo.com/v1.0/reference#about-authentication
 
To send order data to Yotpo, you'll need to generate a user token (UTOKEN).  Yotpo documentation on how to do this can be found at https://core-api.yotpo.com/v1.0/reference#about-authentication
  
Once you have your user token, copy the code snippet below, and paste it into the "xxx" filed on the Preferences -> Checkout & Payment section of your store's admin.  You'll need to update the APPKEY and UTOKEN in the code with your Yotpo App Key and your Yotpo User Token.<br><br>
+
We use the [https://www.postman.com/ Postman App] to generate the token, so you may b able to as well.
 +
 
 +
Once you have your user token, copy the code snippet below, and paste it into the "Additional Content & Scripts" field in the Preferences -> Checkout & Payment section of your store's admin.  You'll need to update the APPKEY and UTOKEN in the code with your Yotpo App Key and your Yotpo User Token.<br><br>
  
 
<pre>
 
<pre>

Revision as of 14:20, 12 May 2021

If you've already added the Yotpo Reviews Widget, you now have the option of adding the Mail After Purchase function. This process takes a few steps, but the benefit from this is that you can collect reviews to display in your store automatically, rather than emailing your customers manually or using a service like MailChimp to email your customers.

The setup cost of the Yotpo Mail After Purchase function is a one-off fee of $35 AUD. To have us set it up for you, please email us with the following information...

  1. The email address and password you use to log in to Yotpo. They need to be for the xxx of the Yotpo account, as we cannot generate keys without admin access.

  2. Your Yotpo App Key and Secret Key

  3. Your St0roe's name

Retrieving your Yotpo App Key and Secret Key

App Key

  1. Log in to your Yotpo Dashboard
  2. Hover over the person icon in the top right, and click "Settings".
  3. Scroll down to the bottom of the page and copy your APP Key
  4. Paste your App Key into the email you send us.

Secret Key

  1. To retrieve your secret key, you'll need to click the "Get Secret Key" button.
  2. A link will be sent to you with a code
  3. Paster the code from the email into the "Enter the code" box
  4. Your Secret key will now be displayed.
  5. Paste your Secret Key into the email you send us.

When you have all the info we need, please email us with this info, and request that we add the conversion code to your store for you.

Want to do it yourself?

To send order data to Yotpo, you'll need to generate a user token (UTOKEN). Yotpo documentation on how to do this can be found at https://core-api.yotpo.com/v1.0/reference#about-authentication

We use the Postman App to generate the token, so you may b able to as well.

Once you have your user token, copy the code snippet below, and paste it into the "Additional Content & Scripts" field in the Preferences -> Checkout & Payment section of your store's admin. You'll need to update the APPKEY and UTOKEN in the code with your Yotpo App Key and your Yotpo User Token.

<! -- Yotpo mail after purchase -->

<script>

$(document).ready(function(){
  var data = JSON.stringify({
	"platform": "general",
	"utoken": "<UTOKEN>",
	"email": "{{ customer.email }}",
	"customer_name": "{{ customer.first_name }}",
	"order_id": "{{ order_name }}",
	"order_date": "{{ order_date | date: "%Y-%m-%d" }}",
	"currency_iso": "{{ shop.currency }}",
	"products": {% for item in line_items %}{
		"{{ item.sku }}": {
			"url": "{{ item.product.url }}",
			"name": "{{ item.title }}",
			"image": "{{ item | img_url: '2048x2048' }}",
			"price": "{{ item.price | money_without_currency }}"
		}{% unless forloop.last %},{% endunless %}{% endfor %}
	}
  });

  var xhr = new XMLHttpRequest();
  var url = "https://api.yotpo.com/apps/<APPKEY>/purchases/";
  xhr.open("POST", url, true);
  xhr.setRequestHeader("Content-Type", "application/json");
  xhr.onreadystatechange = function () {
    if (xhr.readyState === 4 && xhr.status === 200) {
        var json = JSON.parse(xhr.responseText);
        console.log(json);
    }
  };
  xhr.send(data);

});

</script>

<! -- End Yotpo mail after purchase -->