WordPress: Kugwiritsa Ntchito jQuery Kuti Mutsegule Zenera La LiveChat Podina Ulalo kapena Batani Pogwiritsa Ntchito Elementor

Kugwiritsa ntchito jQuery kuti mutsegule Zenera la LiveChat Podina Ulalo kapena Batani Pogwiritsa Ntchito Elementor

M'modzi mwamakasitomala athu watero Zowonjezera, imodzi mwamasamba olimba kwambiri omanga masamba a WordPress. Takhala tikuwathandiza kukonza zotsatsa zawo m'miyezi ingapo yapitayi, kuchepetsa makonda omwe adakhazikitsa, ndikupangitsa kuti makina azilumikizana bwino - kuphatikiza ndi ma analytics.

Wogula watero LiveChat, ntchito yochezera yosangalatsa yomwe ili ndi kuphatikiza kolimba kwa Google Analytics pagawo lililonse la macheza. LiveChat ili ndi API yabwino kwambiri yophatikizira patsamba lanu, kuphatikiza kukhala ndi mwayi wotsegula zenera la macheza pogwiritsa ntchito chochitika cha onClick pa tag ya nangula. Umu ndi momwe zimawonekera:

<a href="#" onclick="parent.LC_API.open_chat_window();return false;">Chat Now!</a>

Izi ndizothandiza ngati mutha kusintha khodi yapakati kapena kuwonjezera HTML yokhazikika. Ndi ZowonjezeraKomabe, nsanjayo imatsekedwa chifukwa chachitetezo kuti musawonjezere onClick chochitika ku chinthu chilichonse. Ngati muli ndi mwambo wa onClick womwe wawonjezeredwa ku code yanu, simupeza cholakwika chilichonse ...

Kugwiritsa ntchito jQuery Listener

Cholepheretsa chimodzi cha njira ya onClick ndikuti muyenera kusintha ulalo uliwonse patsamba lanu ndikuwonjezera nambalayo. Njira ina ndikuphatikiza script patsamba lomwe akumvera podina pang'ono patsamba lanu ndipo imakupangirani code. Izi zitha kuchitika poyang'ana chilichonse nangula ndi yeniyeni CSS kalasi. Pankhaniyi, tikupanga tag ya nangula yokhala ndi kalasi yotchedwa openchat.

M'munsi mwa tsambali, ndikungowonjezera gawo la HTML lachizolowezi ndi zolemba zofunika:

<script>
document.addEventListener("DOMContentLoaded", function(event) {
  jQuery('.openchat a').click(function(){
    parent.LC_API.open_chat_window();return false;
  });
});
</script>

Tsopano, kuti script ndi malo lonse kotero mosasamala tsamba, ngati ndili ndi kalasi openchat kuti adina, izo kutsegula macheza zenera. Kwa chinthu cha Elementor, tangoyika ulalo ku # ndi kalasi ngati openchat.

elementor link

elementor advanced zoikamo makalasi

Zachidziwikire, ma code amatha kukulitsidwa kapena atha kugwiritsidwa ntchito pamtundu wina uliwonse, monga a Chochitika cha Google Analytics. Zachidziwikire, LiveChat ili ndi kuphatikiza kopambana ndi Google Analytics komwe kumawonjezera zochitika izi, koma ndikuziphatikiza pansipa mwachitsanzo:

<script>
document.addEventListener("DOMContentLoaded", function(event) {
  jQuery('.openchat a').click(function(){
    parent.LC_API.open_chat_window();return false;
    gtag('event', 'Click', { 'event_category': 'Chat', 'event_action':'Open','event_label':'LiveChat' });
  });
});
</script>

Kupanga tsamba ndi Elementor ndikosavuta ndipo ndikupangira nsanja. Pali gulu lalikulu, matani azinthu, ndi Zowonjezera Zowonjezera za Elementor zomwe zimakulitsa luso.

Yambani ndi Elementor Yambani ndi LiveChat

Kuwululidwa: Ndikugwiritsa ntchito maulalo othandizira Zowonjezera ndi LiveChat m'nkhaniyi. Tsamba lomwe tidapanga yankho ndi a Wopanga Hot Tub pakati pa Indiana.