我想跟踪我网站上搜索字段中的字词。这些条款应转移到我的跟踪工具(etracker)。 etracker可以通过onmouseclick事件获得它。
这是我目前的代码:
<div class="form-group autocomplete">
<div class="input-group search">
<input id="search" name="searchterm" type="search" class="form-control form-control search-input" placeholder="Please enter a search term" autocomplete="off">
div class="input-group-btn">
<button type="submit" class="btn color-cta-3 search-button" onmousedown="ET_Event.eventStart('searchterm', 'search')">Search</button></div></div>
我需要的是n JavaScript,它会将输入的搜索词从输入字段复制到onmousedown事件。它有可能吗?也许类似“searchterm.value = variablexy”+事件代码中的变量?
答案 0 :(得分:0)
单击按钮时,它会获取搜索条件,然后在从输入传递文本时调用ET_Event.eventStart
函数(如果它是js函数)
function getInput(){
ET_Event.eventStart(document.getElementById('search').value, 'search')
}
&#13;
<div class="form-group autocomplete">
<div class="input-group search">
<input id="search" name="searchterm" type="search" class="form-control form-control search-input" placeholder="Please enter a search term" autocomplete="off">
<div class="input-group-btn">
<button type="submit" class="btn color-cta-3 search-button" onmousedown="getInput(); return false;">Search</button></div></div>
&#13;