Answer the question
In order to leave comments, you need to log in
How to add a phrase to search statistics?
We have our own search component on the site, but it does not save phrases in search statistics (Settings / Search / Statistics / List of phrases). How can I add phrases to search statistics?
The search is done through the code below:
$obSearch = new CSearch;
$Q = htmlentities($_REQUEST["q"]);
$obSearch->Search(array(
"QUERY" => $DB->ForSql($Q),
"SITE_ID" => LANG,
"MODULE_ID" => "iblock",
"PARAM1" => "catalog"
));
Answer the question
In order to leave comments, you need to log in
Do you have the statistics collection option enabled: Settings / Product settings / Module settings / Search, Statistics tab, checkbox Collect statistics for search phrases?
If yes, then you can add the phrase to the statistics in the same way as Bitrix itself does.
CModule::IncludeModule("search");
if (COption::GetOptionString("search", "stat_phrase") == "Y")
{
$statistic = new CSearchStatistic('kudis.ru', '1С-Битрикс,Битрикс24');
$statistic->PhraseStat(12, 3);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question