Isticmaal jQuery si aad u dhageysato oo aad uga gudubto Dabagalka Dhacdada Google Analytics ee Dhagsi kasta

jQuery Dhageyso dhagsi si aad uga gudubto Dabagalka Dhacdada Google Analytics

Waxaan la yaabay in badan oo isdhexgalka iyo nidaamyada aan si toos ah loogu darin Dabagalka Dhacdada Google Analytics in dhufto ee ay. Inta badan wakhtigayga ka shaqaynta shabakadaha macaamiisha ayaa horumarinaysa la socodka Dhacdooyinka si aan u siiyo macmiilka macluumaadka ay u baahan yihiin ee ku saabsan waxa dabeecadaha isticmaaluhu ka shaqaynayaan ama aan ka shaqaynayn goobta.

Dhawaanahan, waxaan wax ka qoray sida loo raad raaco mailto gujis, tel gujis, Iyo Soo gudbinta foomka Elementor. Waxaan sii wadi doonaa inaan wadaagno xalalka aan qorayo iyadoo rajada laga qabo inay kaa caawiso inaad si fiican u falanqeyso goobtaada ama waxqabadka codsiga shabakada.

Tusaalahani wuxuu bixiyaa hab aad u fudud oo lagu darayo Dabagalka Dhacdada Google Analytics ee summada barroosinka iyadoo lagu darayo qayb xog ah oo ay ku jirto Qaybta Dhacdada Google Analytics, Falka Dhacdada Google Analytics, iyo Summada Dhacdada Google Analytics. Halkan waxaa ah tusaale isku xidhka ku dara qaybta xogta, ee loo yaqaan dhacdo:

<a href="#" data-gaevent="Category,Action,Label">Click Here</a>

Shuruudaha looga baahan yahay goobtaada waxaa ku jira jQuery… kaas oo qoraalkan ku shaqeeya. Marka boggaaga la shubo, qoraalkani wuxuu ku darayaa dhegeyste boggaaga qof kasta oo gujinaya shay leh dhacdo xogta...kadibna waxa ay qabataa oo ay kala saartaa qaybta, falka, iyo calaamadaynta aad ku qeexday goobta dhexdeeda.

<script>
  $(document).ready(function() {      
    $(document).on('click', '[data-gaevent]', function(e) {
      var $link = $(this);
      var csvEventData = $link.data('gaevent');
      var eventParams = csvEventData.split(',');
      if (!eventParams) { return; }
        eventCategory = eventParams[0]
        eventAction = eventParams[1]
        eventLabel = eventParams[2]
        gtag('event',eventAction,{'event_category': eventCategory,'event_label': eventLabel})
        //alert("The Google Analytics Event passed is Action: " + eventAction + ", Category: " + eventCategory + ", Label: " + eventLabel);
    });
  });
</script>

Ogeysiis: Waxaan ku daray digniin ( faallo ka bixisay) si aad u tijaabiso waxa dhabta ah ee la gudbay.

Haddii aad ku dhex wado jQuery WordPress, waxaad u baahan doontaa inaad wax ka bedesho koodka wax yar maadaama WordPress aanu qadarin $ shortcut:

<script>
  jQuery(document).ready(function() {      
    jQuery(document).on('click', '[data-gaevent]', function(e) {
      var $link = jQuery(this);
      var csvEventData = $link.data('gaevent');
      var eventParams = csvEventData.split(',');
      if (!eventParams) { return; }
        eventCategory = eventParams[0]
        eventAction = eventParams[1]
        eventLabel = eventParams[2]
        gtag('event',eventAction,{'event_category': eventCategory,'event_label': eventLabel})
        //alert("The Google Analytics Event passed is Action: " + eventAction + ", Category: " + eventCategory + ", Label: " + eventLabel);
    });
  });
</script>

Ma aha qoraalka ugu adag waxaana laga yaabaa inaad u baahato inaad samayso nadiifin dheeraad ah, laakiin waa inay ku bilaabataa!