VOOZH about

URL: https://support.google.com/merchants/answer/16961497

⇱ Step 5 of 5: Set up discounted prices in your online store - Google Merchant Center Help


Skip to main content

Set up automated discounts

Step 5 of 5: Set up discounted prices in your online store

Set up your online store to show discounted prices and prior prices (for EEA countries) from Google-generated JSON Web Tokens (JWT), which are included in web addresses (URLs) from your Shopping ads.

Requirements: Discounted prices must show in the following places.

  • On product landing pages for at least 30 minutes, even if customers revisit a product page and the JWT is no longer in the URL.
  • In the cart and checkout process for at least 48 hours.

👁 Product landing page of a green candle with the original price crossed out and sale price in red.

Step 5a: Show discounted prices from Google-generated JSON Web Tokens (JWT)

JWT structure

Refer to the following JWT structure when you set up your online store.

JWTs contain two objects: header and payload.

JWT header


{

"alg" : "ES256",

"typ" : "JWT"

}


Google-generated JWT headers have 2 fields:

  • alg — used algorithm, value is always "ES256"
  • typ — media type, value is always "JWT"

If the JWT header contains any other fields or field values that are different from the required values, the token must be rejected.

JWT payload


{

"exp" : 1571673600,

"m" : "140301646",

"o" : "tddy123uk",

"c" : "USD",

"p" : 21.99,

"pp" : 15.00

}


The JWT payload includes the following fields:

  • exp — Expiration time as Unix time. If the token is expired, it must be rejected.
  • m — Merchant ID. If the merchant ID doesn't match, the token must be rejected.
  • o — Offer ID, used to check if the product page matches the product or a valid variant, such as a different size of the same shoes. If the product page doesn't match the product or a valid variant, the token must be rejected.
  • c — Currency in ISO 4217 format.
  • p — Price from automated discounts.
  • pp — Prior price from your Shopping ads.

Prior price for countries within the European Economic Area (EEA): You may choose to show the prior price in your online store. The prior price will be included in the URL if the prior price is shown in your Shopping ad.

  • For Croatia, Latvia, Norway, Poland, and Spain: The prior price represents the previous lowest price shown to users on Google in the past 30 days before the latest price reduction.
  • For all other EEA countries: The prior price represents the previous lowest price shown to users on Google in the past 30 days before the latest price reduction, except when consecutive price reductions are applied (for example, 10% off, then 20% off, then 50% off) within the past 60 days. If consecutive price reductions are applied, the prior price will be the price that was applied before the first price reduction.

Example of prior price for EEA countries after consecutive price reductions:

Day 1, price before first reduction: 100€
Day 7, first price reduction: 90€
Day 14, second price reduction: 80€
Day 21, third price reduction: 70€

Prior price after the third price reduction:

  • 80€ (previous lowest price) for Croatia, Latvia, Norway, Poland, and Spain
  • 100€ (price before first reduction) for all other EEA countries

Consuming the token

There are 3 general steps to consume the token depending on the library you use: decoding and signature validation, field validation, and consuming price.

  1. Decode the token and validate the signature.
    Most libraries combine decoding and signature validation into a single function, where 'token," "ES256" (algorithm), and "public key" are inputs, and "token_body" is the output:

    token_body = decode(token, 'ES256', public_key)


    1. Decode the Base64URL encoded token, which is passed in a pv2 URL request parameter:

      http://my.site.com/blacktee?pv2=eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJjIjoiVVNEIiwiZXhwIjoxNTcxNjczNjAwLCJtIjoiMTQwMzAxNjQ2IiwibyI6InRkZHkxMjN1ayIsInAiOjIxLjk5fQ.Qlyr1dQ0vLUJx-iQKwkYE2uLHfYCLVEVGZkAq4fwGTSpMDQCbtzDJr5uGHG8dNKaKV5OlYDxLpW40tQVVe2gk


    2. Copy the following public key exactly as it appears and use it to validate the signature.

      -----BEGIN PUBLIC KEY-----

      MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAERUlUpxshr67EO66ZTX0Fpog0LEHc nUnlSsIrOfroxTLu2XnigBK/lfYRxzQWq9K6nqsSjjYeea0T12r+y3nvqg==

      ----END PUBLIC KEY-----


      Note that this public key doesn’t expire and follows the Privacy-Enhanced Mail format.
  2. Validate the header and payload fields.
    • Header: If your library accepts the key and algorithm, as described in the previous step, and forces their use despite header options, there's no need for additional header checks. Otherwise, check the header fields according to the guidelines previously described. For more information, review the JSON Web Token best practices.
    • Payload:
      • Validate the o, m, and p fields against merchant-side data. If they don't match, the token must be rejected to prevent customers from copying and using tokens from other products or merchants.
      • Validate the exp field. Tokens are valid for 60 minutes. If a token is expired, it must be rejected to prevent customers from using expired tokens.
  3. Consume the price.
    If all fields are valid and the token isn't expired, show the price provided in the p field. For EEA countries, you may also show the prior price provided in the pp field.
Requirements: Discounted prices must show in the following places.
  • On product landing pages for at least 30 minutes, even if customers revisit a product landing page and the JWT is no longer in the URL.
  • In the cart and checkout process for at least 48 hours.

Step 5b: Test discounted prices

  1. Test the functionality with a temporary key pair, which gives you full control over the tokens.
    Use the following command to generate a valid key pair:

    $ openssl ecparam -genkey -name prime256v1 -noout -out privkey.pem
    $ openssl ec -in privkey.pem -pubout -out pubkey.pem


    Generate tokens with JWT Debugger or a similar tool that uses the ES256 algorithm.
  1. Validate the production keys with the signed tokens that are available in Merchant Center. To do so, in your Merchant Center account, go to the Automated discounts tab in the "Marketing" section, and click the test links for sample products.

Step 5c: Request a review

Your setup will be reviewed within 2-3 business days to confirm whether discounted prices show as required in your online store.

  • In your account, go to the Automated discounts tab in the “Marketing” section, and select Request review at the bottom of the page.

You’ll be notified by email when automated discounts is activated or if there are issues you’ll need to fix.

Any issues will be shown on the Automated discounts page. After you fix all issues, request another review. Allow up to 24 hours for any changes that you make to be reflected in Merchant Center.


Related links

Was this helpful?

How can we improve it?
false
Search
Clear search
Close search
Google apps
Main menu
11647071228084459395
true
Search Help Center
false
true
true
true
true
true
71525
false
false
true
false
false