The Dynamic Yield Magento Extension provides quick and seamless integration with Dynamic Yield and enables automatic implementation of the Dynamic Yield eCommerce solution that includes:
- Dynamic Yield tracking script implementation
- Context API implementation
- e-commerce events implementation
- Product feed (catalog) export
The Magento extension is compatible with both the Enterprise and the Community editions, and supports the following event types:
- Purchase
- Add to cart
- Signup
- Login
- Newsletter subscription
- Add to wishlist
- Remove from cart
- Sort items
- Filter items
- Change attribute
- Promo code entered
- Search
Note: Bundled products are not supported and are not migrated to Dynamic Yield.
Integration Requirements
The integration is built on some assumptions about your Magento environment. If any of the following assumptions are not true, speak to your Customer Success Manager to see if this method of implementation is supported for your environment.
- Your Magento site is built on one data feed that maps to one Dynamic Yield site. The site can manage one storefront, or multiple translations of the same storefront.
- There are fewer than 150,000 products in your product feed. If you have more products, you can disable the feed sync in Magento and upload a feed manually. For details, see Creating and Syncing Data Feeds.
- The store theme has not been heavily customized in such a way as to make the DOM element data difficult to access using JavaScript.
- The Magento core code has not been modified directly or extended incorrectly.
- If you are managing stock availability per locale using a plugin in Magento, your feed must sync to Dynamic Yield manually. For details, see Creating and Syncing Data Feeds.
Mapping store views to Dynamic Yield sites
By default, you connect your entire Magento site, including all store views, to a single Dynamic Yield site. If you have different store views that represent any case other than multiple translations of the same store, you need to link each store view to a different Dynamic Yield site.
This requires you to manually sync a different data feed for each site using the standard procedure, and not using this integration. All other items (events, page context, and script), are handled by this extension.
Note: Spaces in SKUs are replaced with underscores (for example, SKU: 63 2 becomes SKU: 63_2).
To map a single store view to a Dynamic Yield site, when defining the Site ID field in the following procedure, define the relevant Store View using the dropdown at the top-left of the screen. In the Site ID field, uncheck the Use Default option and specify the relevant Dynamic Yield site ID.
Installing the Magento extension
- Go to the Magento 2 root in a command prompt and enter the following command:
cd <magento2-root>
- Add extension repository to composer config using the following commands:
composer config repositories.dynamic-yield/integration vcs https://github.com/DynamicYield/dy-magento-integration
- Require extension using composer with the following command:
This can take up to 10 minutescomposer require "dynamic-yield/integration" --update-no-dev
- Change directory to Magento 2 bin directory, so you can enable the extension as follows:
cd bin/
- Make sure that the module has been successfully required by composer typing following commands in command prompt:
This should return the following:php magento module:status
List of disabled modules: DynamicYield_Integration
- Enable maintenance mode by typing following commands in command prompt:
php magento maintenance:enable php magento cache:clean
- Enable module by typing following commands in command prompt:
You should receive a message indicating the module has been enabled in the command prompt.php magento module:enable DynamicYield_Integration
- Make sure that the enabled modules are properly registered by typing following commands in command prompt:
php magento setup:upgrade --keep-generated
- Deploy module static view files by typing following commands in command prompt:
php magento setup:static-content:deploy
- Flush Magento 2 cache storage, by typing following commands in command prompt:
php magento cache:flush
- Disable maintenance mode by typing following commands in command prompt:
php magento maintenance:disable
- If you are using versioning system such as “Git”, commit these changes to your project repository by typing following commands in command prompt:
cd .. git add composer.json composer.lock && git commit -m "Added dynamic-yield/integration module" && git push
Important notes:
- If Varnish or any similar caching solution is in use, make sure that the Dynamic Yield blocks are not cached. In certain cases hole-punching might be necessary.
- If you are using a custom template and the template uses HTML classes other than the default, adjust those fields so the Dynamic Yield integration can work properly. For details, see Advanced Settings below.
Configuration
- In the Magento admin, go to Stores › Configuration.
- Open the Dynamic Yield › Integration.
- In the Settings section, fill in the fields:
- In the Site ID section, enter your Dynamic Yield site ID.
- This is a store view level configuration, which means that it is possible to set different Site ID for each store view.
- Product feed uses default value and remains a global configuration.
- If you have multiple Store Views representing anything other than multiple translations of the same store, see the previous section, Mapping Store Views to Dynamic Yield Sites.
- In the Access Key ID, enter the value provided by your Customer Success Manager. This gives the extension access to your AWS S3 bucket. This configuration is global and therefore affects all stores and store views in this instance of Magento.
- Enter the Secret Access Key provided by your Customer Success Manager. This gives the AWS bucket access to the feed storage. This configuration is global and therefore affects all stores and store views in this instance of Magento.
- In the Site ID section, enter your Dynamic Yield site ID.
- In the Product Catalog Sync section, fill in the fields:
- Enable Product Feed Sync: This should be enabled, unless your feed is not standard and must be manually synced (see Integration Requirements above). If you disable the sync, you do not need to configure any of the other settings in this step.
- Sync rate: Sync rate configurations stands for Dynamic Yield export feed, how often you want it to be updated in Dynamic Yield service side.
- Product Attributes: Enhance your personalization capabilities by syncing up to 10 additional key product attributes (mandatory attributes are already selected). Select attributes by clicking attributes and clicking Save. Attributes then will be transferred to section below – Used Product Attribute.
- Used Product Attribute: Here you can see which attributes are selected. To remove attributes, click on attribute and then press Save button above. Attribute then will be removed for Used Product Attribute.
Note: You should not deselect an attribute after the feed has synced. Contact your CSM for additional information
- Exclude Categories: Categories that will be excluded from the product feed column – “categories”. These categories will be reported in the column “keywords”. This is designed for categories that are temporary such as “winter sale”, which do not represent the main category tree but are still valuable. If excluded, these categories will still be reachable via the keywords column.
- Category Trees: Define a root category for each store scope. Leave empty if all trees are included in all store views.
- Debug Mode: Enable product feed debug mode. The logs are written to a file dyi_feed.log.
All configurations are global and apply to all stores and store views in this instance of Magento.
- The Custom Locale section can be used to make sure the page context is configured properly for each translated version of your site. For more details, see Validating Multi-Language Sites below.
- Expand the Integration Type section and complete the following settings:
- Enable Dynamic Yield Europe Account: Set this field to “Yes” to enable the Dynamic Yield Europe account. This setting will adjust the tracking script URLs and product feed upload URL. No other configuration is necessary.
- Enable CDN integration: If you choose “Yes” or “European” an input field to write your own CDN URL is shown (choose “Yes”). If “European” is chosen the product feed bucket endpoint URL is changed.
- CDN URL: You can write your custom CDN URL that will be used to include the tracking scripts.
Advanced settings
If you are using a custom template and the template uses HTML classes other than the default, you need to adjust those fields so the Dynamic Yield integration can work properly. For Magento versions 2.2 and higher, the Developer tab and options are only available in Developer Mode.
- Go to System › Configuration › Advanced › Developer in the admin panel.
- Expand the Dynamic Yield Integration section.
- Triggers: These configuration values expect a CSS selector (element, class, id) of the element that will trigger the action. An event listener is attached to this element. In case the DOM element is not found the event will not be attached and that particular event will not be tracked. To find the appropriate selector inspect the source code of the page and find the element that is responsible for triggering the filter/sort/change functionality. This can be any element (div/select/a/span). Usually just clicking on the element to inspect source is enough to find it, but sometimes it is more convenient to select the parent or child element.
- Type and Value: After you find the trigger element, you must next extract 2 values – type and value (filter type: Size, filter value: Green). To extract these you need to configure the Value and Type configuration fields. These fields show the DOM structure relative to the trigger element and are used to extract the type and value data. The structure (Type and Value) configs expect a JSON type string where keys are functions and values are function parameters. Any function that is available in the given scope can be used in the structure. Here is an example:
- Filter can have multiple types – attribute, text-based swatch, image-based swatch, and so on. Therefore, there are multiple configuration values for each type. Fill in necessary fields according to your requirements. If you do not use a particular type of filter you can leave the configuration as-is or leave the field empty.
- Configuration is store scope so it is possible to set different selectors for each store view.
Validation
It is important to validate that your script, page context, data feed, and events have been set up properly. This is done using the Implementation Status Dashboard and the Web Implementation Helper.
See Validating Your Web Implementation for help with validation.
If you have multiple store fronts representing different translations of your site, see Validating Multi-Language Sites below. If you have any issues with the Purchase event, see Troubleshooting Purchase Events below. If you have cannot validate your Product Feed, see Troubleshooting your Product Feed below.
Validating multi-language sites
If you have multiple storefronts representing different translations of your site, it is important to validate that the page context is properly aligned for each site. This is in addition to the standard page context validation procedure.
- Go to one of your websites and open the browser console.
- Locate the page context by searching for DY.recommendationContext.
- Verify that the lng parameter is aligned with the language of the page.
- Repeat this procedure for each translated version of your site.
- If you find one or more lng parameters that are not aligned with your site, you can update it in the plugin settings.
- Go to System › Configuration › Advanced › Developer in the Dynamic Yield console.
- Expand the Dynamic Yield Integration section.
- Set the Enable Custom Locate setting to true and use the dropdown list to select the correct language for the store view that is currently selected. Repeat for every store view.
- If the dropdown list doesn't have the correct language setting, set Set Custom Locate to true and specify the language string in the Custom Context Store Locale field (for example, de_DE).
Troubleshooting purchase events
The integration uses default Magneto events which work for default Luma and built-in modules. So if a third-party payment/checkout module is used you need to make sure that these events are triggered (or add observers to your custom events) during purchase:
Magento2 – checkout_onepage_controller_success_action
Troubleshooting your product feed
If you could not successfully sync your product feed, use the following checklist to verify that all required settings are configured before contacting customer support.
- Verify that the Enable Product Feed Sync setting is enabled in Magento. For details, see the section Mapping store views to Dynamic Yield sites.
- Check the Site ID, Access Key, and Secret Key settings and make sure they are correct.
- Verify that cron is running on your Magento site.
- Verify that the feed file is created on the server: {magento_root}/var/dyi_export/productfeed.csv
FAQs
Does the extension support Varnish full-page caching?
Yes, the extension works with Varnish full-page caching. If Varnish or a similar caching solution is used make sure that the Dynamic Yield blocks are not cached. In certain cases hole-punching might be necessary.
If I use a third-party search extension, will the search event work?
In most cases, yes, but if this extension does not follow the Magento default built-in class hierarchy, contact us so we can create a custom solution for you.
The Sort event is not working, what should I do?
If you are using a custom template there may be some problems with the Sort event as it is strictly made for default Magento templates. Please contact us to make a custom solution for you.
The Change attribute event is not working, what should I do?
The extension is created to work with default Magento functionality in some cases 3rd party extensions control for product page attributes. If so, please contact us so we can make a custom solution for you.
An event specified above is not working. What should I do?
This might be due to a conflict between Magento extensions. Contact Support to evaluate the issue.
I’m getting a message “DynamicYield Integration: Products missing mandatory attributes. Details: dyi_skipped_products.log”
Products are validated to make sure that all of the mandatory attributes are set. If you are receiving this message, it means that some products were skipped during the product feed export. The skipped products are listed in the dyi_skipped_products.log.