Injecting the TRUENDO Script into Shopware Theme via Admin Interface

Overview#

This guide walks you through the steps to inject the TRUENDO script into your Shopware theme via the admin interface, ensuring it is added as the first script to load.

Prerequisites#

  1. Access to your Shopware Admin Panel.
  2. The TRUENDO script to be injected:
<script id="truendoAutoBlock" type="text/javascript" src="https://testcdn.priv.center/pc/truendo_cmp.pid.js" data-siteid="YOUR_SITE_ID"></script>

Replace YOUR_SITE_ID with your actual TRUENDO Site ID.

  1. Basic knowledge of Twig template customization.

Steps to Inject the Script#

Step 1: Access Theme Manager

  1. Log in to your Shopware Admin Panel.
  2. Navigate to Content > Themes.
  3. Select the active theme you are using for your Shopware storefront.

Step 2: Customize the Theme

  1. Click on the Edit Theme button for your active theme.
  2. Locate the Theme Files section or option to edit template files.
  3. Look for the base.html.twig file, typically located under the storefront/base.html.twig path.

Step 3: Modify the base.html.twig File

  1. Open the base.html.twig file for editing.
  2. Locate the base_head block within the file.
  3. Add the TRUENDO script at the beginning of the block to ensure it loads first.

Example Modification:

{% block base_head %} <script id="truendoAutoBlock" type="text/javascript" src="https://cdn.priv.center/pc/truendo_cmp.pid.js" data-siteid="YOUR_SITE_ID"></script> {{ parent() }} {% endblock %}

By placing the script before {{ parent() }}, it ensures that your TRUENDO script loads before any other scripts.

Step 4: Save and Apply Changes

  1. Save your changes to the base.html.twig file.
  2. Clear Shopware's cache to apply the changes. Use the following command if you have terminal access:

    bin/console cache:clear

    Alternatively, clear the cache through the Shopware Admin Panel under Settings > Cache & Indexes.

Step 5: Verify the Script

  1. Open your storefront in a browser.
  2. Inspect the page source or use developer tools (F12) to confirm that the TRUENDO script is loaded as the first script in the <head> section.

Troubleshooting#

  • Script not loading: Double-check the base.html.twig file and ensure the script is placed correctly.
  • Cache issues: Ensure the Shopware cache is cleared after making changes.
  • Incorrect Site ID: Verify that the correct data-siteid value is used in the script.

Additional Notes#

  • If multiple themes are active or used, repeat this process for each theme.
  • For advanced requirements, consider creating a custom plugin instead of directly modifying theme files.

This guide provides a simple, admin-based approach to injecting the TRUENDO script. For further assistance or advanced integration, consult the Shopware documentation or contact TRUENDO support.

×