{"section":"tutorials","requestedLocale":"en","requestedSlug":"configuring-viewed-product-email","locale":"en","slug":"configuring-viewed-product-email","path":"docs/en/tutorials/master-data/master-data-v1-triggers/configuring-viewed-product-email.md","branch":"main","content":"> ⚠️ This tutorial is only applicable to Legacy CMS Portal stores.\n\nThe viewed product email is an automatic message sent to customers who have accessed a product page on the site but have not placed an order. The purpose of sending this  email is to recover the sale and offer other products.\n\nYou can configure this type of email trigger using Master Data. To do this, follow the instructions in the next sections:\n\n1. [Setting a minimum trigger range](#setting-a-minimum-trigger-range)\n2. [Displaying fields on the form](#displaying-fields-on-the-form)\n3. [Creating an email template for viewed products](#creating-an-email-template-for-viewed-products)\n4. [Creating a folder structure](#creating-a-folder-structure)\n5. [Configuring the email trigger](#configuring-the-email-trigger)\n\n> ⚠️ Your store must have a high flow of visits and orders for this feature to work properly since shelves are created based on browsing data for a specific product.\n\n## Setting a minimum trigger range\n\nSetting a trigger range means limiting the minimum time between one trigger and another for sending an email to the same customer. This prevents the customer from receiving multiple emails during the same navigation session in the store.\n\nTo configure this range, create a field in the **CL** entity.\n\n1. In the VTEX Admin, go to **Store Settings** > **Storefront** > **Master Data**.\n2. In Master Data, click **Apps** > **Data Structure**.\n3. Click the **Data Entities** tab.\n4. In the **Customer** entity, click the pencil icon.\n5. Click the `New Field` button.\n6. Complete the fields, as described below:\n    * **Name**: lastTrigger.\n    * **Display name**: Date of last trigger sent.\n    * **Type**: Date and Time.\n7. Click the `Save` button.\n\n## Displaying fields on the form\n\nAfter creating a field in the entity, you must configure the field to display on the form to be able to see the information it contains. This is also valid for fields created automatically by VTEX but that are not flagged to be displayed on the form.\n\nFollow the steps below to display the important fields for the viewed products scenario:\n\n1. In the VTEX Admin, go to **Store Settings** > **Storefront** > **Master Data**.\n2. In the **Profile System** application, click the gear icon <i class=\"fas fa-cog\"></i>.\n3. Click the pencil icon <i class=\"fas fa-pencil-alt\"></i> on the **Customers** form.\n4. Click the **Layout Schemas** tab.\n5. Click the `Add New Section` button.\n6. Add a name to your section.\n7. In the **Available Fields** column, drag the desired field to the **Fields of Column 1** area below the name of the created section.\n8. Click the `Save` button.\n\n## Creating an email template for viewed products\n\nThe email template that will be sent must be configured in the Legacy CMS Portal, following the steps below. To help with the configuration, you can use the[ example template](https://assets.ctfassets.net/alneenqid6w5/6TloqmkC76AAauQ4e4SWmA/cf62e0e8ae5ab674d66362def45ec653/product-visited-en.zip).\n\n1. In the Admin, go to **Storefront > Layout**.\n2. Click `CMS` and then **HTML Templates**.\n3. Click **new template**.\n4. Enter the name and paste the code of your template. If you're using the example template, remember to change the SHELF TEMPLATE code to the ID of your shelf template and the STORE_NAME code to your store URL. You also need to change the image files.\n5. Click the `Save Template` button.\n\n### Sent products\n\nThe control that displays the viewed product is `ProductQueryStringReferenceShelf`, and the control that displays the shelves of similar products is `<vtex.cmc:productsCrossSelling … crossSellingType=\"1\" />`. The parameter `crossSellingType` ranges from 1 to 6:\n\n- **1**: People who viewed this item also viewed\n- **2**: People who viewed this item also bought\n- **3**: People who bought this item also bought\n- **4**: Similar products\n- **5**: Suggestions\n- **6**: Accessories\n\nThe first three shelves are set up automatically by the system, and the last three are configured [manually in the product settings](/en/tutorial/configurando-produto-similar-sugestoes-acessorios-e-genericos/).\n\n## Creating a folder structure\n\nAfter creating the template, you must create the folder structure required for configuring the trigger. Follow the steps below:\n\n1. In the Admin, go to **Storefront > Layout**.\n2. Click **CMS** > **Sites and channels**.\n3. Click your store.\n4. Click the / folder and then the **CEM** folder.\n5. Click **new folder**.\n6. Complete the fields, as described below:\n    * **Folder Name**: Viewed-product\n    * **Protocol**: HTTPS\n    * **Authentication Required?**: Leave it unchecked.\n7. Click the `Save Folder` button.\n8. Once the folder has been created, you must link the page template to the layout. Click the created folder in the left-hand side menu of the Legacy CMS Portal.\n9. Click **new layout**.\n10. In **Template**, select the template created previously.\n11. Click the `Save Layout` button.\n\n## Configuring the email trigger\n\nTo configure the trigger, follow the instructions below:\n\n1. Access `{storename}.ds.vtexcrm.com.br`, replacing `{storename}` with your VTEX account name.\n2. Log in as required.\n3. Click the **Trigger** tab.\n4. Click `Add New`.\n5. Complete the fields:\n    * **Name:** Enter the trigger name.\n    * **Data entity:** Select the data entity the trigger belongs to.\n    * **Status:** Check the **Enabled** option.\n6. In the **Rules** tab, in the field **Trigger rule**, select **An attribute value is changed**.\n7. In **Field**, select** Visited Product**.\n8. In **Additional filter**, click `Add Filter`. Configure two filters as described below:\n    * _Checkout – Is null – and_\n    * _Viewed Product - Is not null - and_\n9. Click the `Add Group` button.\n10.  Click `Add Filter` to add a filter to the group. Complete as described below:\n    * _Date of last trigger sent - Less than or equal to - CURRENT DATE - Minus days - 7 - or_\n    * _Date of last trigger sent - Is null_\n11. 11. Click the **Schedule** tab.\n12.  Select one of the trigger scheduling options. Example: Schedule on a dynamic date, such as _CURRENT DATE - plus - 2 hours_.\n13.  Click the** If Positive** tab.\n14. Complete this tab as follows:\n    * **Action**: Select **Send an email**.\n    * **Recipient**: Enter your email as a test, and click `Add Static Email`. After the test, delete your email, select **CL: Email**, and click `Add Dynamic Email`.\n    * **Email body format**: Select **HTML**.\n    * **Sender's name**: Enter the name of your store as you want it to be displayed on the email sender.\n    * **Reply to**: Enter the email address to which the customer can reply.\n    * **Content type**: Select **URL content**.\n    * **Subject**: Complete the subject of the email.\n    * **URL**: Enter your store's address with the folders in which the layout of the viewed product has been configured. Example: `storename.com/CEM/Viewed-Product?refp={!productVisitedTag}`. Pay attention to the end `?refp={!productVisitedTag}`, which needs to be at the end of the URL for the products to be displayed.\n    * **Add utm_source in all links containing values**: Complete with \"CEM\" to facilitate the identification of purchases made via the viewed product.\n    * **Overwrite utm_source:** Check this option.\n15.  Click the `Save` button."}