Diese Seite ist derzeit nicht in Ihrer Sprache verfügbar. Sie können unten auf der Seite eine andere Sprache auswählen. Alternativ lässt sich jede beliebige Webseite mit der integrierten Übersetzungsfunktion von Google Chrome in eine Sprache Ihrer Wahl übersetzen.

Configure Google Analytics 4 (GA4) with Site Search

If you already have a Google Analytics 4 account, you can configure your Google Analytics 4 (GA4) and use Search Element Callback to get a detailed search queries report.

If you do not have a Google Analytics 4 account, you will need to create a Google Analytics 4 account and then configure your Google Analytics 4 account.

Make sure you have enabled Site Search in GA4 to capture a view of search events each time a visitor performs a search on your site:

https://support.google.com/analytics/answer/9216061

Once your Google Analytics 4 (GA4) is configured correctly,  Search Element Callbacks can be used on your website where you have implemented your Programmable Search Engine implementation code and your Google Analytics 4 tracking code.  Your callback should call the GA4 'gtag' function with the 'search' event using the given query.

Example Code:

const myWebSearchStartingCallback = (gname, query) => {

   gtag("event", "search", { search_term: query });

   return '';

};

 

window.__gcse || (window.__gcse = {});

window.__gcse.searchCallbacks = {

  web: {

    starting: myWebSearchStartingCallback,

  },

};

 

 

Another example code to track organic results clicks:

// Define the callback function that runs when results rendered
const myWebResultsRenderedCallback = function() {
  document.addEventListener("click", function(e) {
    // Find if the clicked element is a search result link
    let link = e.target.closest("a.gs-title");

    if (link) {
      let title = link.innerText;
      let url = link.href;
      console.log("Tracking Search Click:", title, url);

      // Send Data To GA4
      gtag('event', 'search_result_click', {
        'event_category': 'engagement',
        'event_label': title,
        'link_url': url
      });
    }
  });
};

 

Configure your Google Analytics 4 to generate report to identify what your visitors search on your website:

https://support.google.com/analytics/answer/9212670

Note: Once all the settings are configured, GA4 reports will take 24/48 hours to reflect the searches performed on your Engine.

For support on queries related to GA4 configuration, please contact:

https://support.google.com/analytics/answer/9026876

https://support.google.com/analytics/gethelp

https://support.google.com/analytics/community

Benötigen Sie weitere Hilfe?

Mögliche weitere Schritte:

Search
Clear search
Close search
Google apps
Main menu
13832677505835615199
true
Suchen in der Hilfe
false
true
true
true
false
false
false
false
false