简体   繁体   English

如何在shopify中跟踪简单的按钮单击事件?

[英]How to track a simple button click event in shopify?

I want to add some javascript like: 我想添加一些JavaScript,例如:

$("#foo").click(function(){
   makeHttpPost();
});

that makes an http request whenever a button with id foo is clicked and i don't see a simple way to add this Javascript. 每当单击ID为foo的按钮时,都会发出http请求,而我看不到添加此Javascript的简单方法。

I saw that you could add an asset file and then reference it in a previous answer but i don't see anywhere to add an "asset". 我看到您可以添加资产文件,然后在上一个答案中引用它,但是我看不到要添加“资产”的任何地方。 I only see a "files" section under settings. 我只在设置下看到“文件”部分。

I'd appreciate a step by step description of what to do and where to find what to do from the admin panel. 我希望能从管理面板中逐步了解如何操作以及在哪里可以找到操作。

Thanks! 谢谢!

To add a new asset, you first click on the "Themes" link in the admin sidebar, and then "Template Editor". 要添加新资产,请先单击管理侧栏中的“主题”链接,然后单击“模板编辑器”。

You can then upload an asset by clicking "Add a new asset" under the asset folder. 然后,您可以通过单击资产文件夹下的“添加新资产”来上传资产。 (See image below) (见下图)

添加新资产

To include the JavaScript file in the HTML, open theme.liquid from the template editor and add the following code in your <head> section (Changing the file name as required). 要将JavaScript文件包含在HTML中, theme.liquid从模板编辑器中打开theme.liquid ,然后在<head>部分中添加以下代码(根据需要更改文件名)。

{{ 'javascriptFileName.js' | {{'javascriptFileName.js'| asset_url | asset_url | script_tag }} script_tag}}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM