We are using the CE2.2.5
as the google adwords, we have to add the event track code to the header section for Specific page. But we do not find such way to realize it.
We can just add the codes to All the page at the Head section.
https://docs.magento.com/m2/ce/user_guide/design/html-head.html
Hello @alenwang9788,
After login admin side, Go to Content > Design > Configuration > Edit global and add code here https://www.screencast.com/t/JPTjPA6ooC
After adding code please clear cache then you will get in head. Let me know if you still got an issue.
--
If my answer is useful, please Accept as Solution & give Kudos
yes, but it is configured for the global header section.
They ask for the Specific page.
e.g if we want to track the order, we need to insert this event's code to the "checkout success" page.
Hello @alenwang9788
You can add your script to any specific header using the specific layout file.
If you want to add your script in the head of checkout success page, create checkout_onepage_success.xml file in your theme and add your script.
app/design/frontend/vendor/theme/Magento_Checkout/layout/checkout_onepage_success.xml
<?xml version="1.0"?> <!-- /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <head> <script src="js/your_script.js" /> </head> </page>