We use Google Tag Manager to collect keywords used in site searches.
By using the form submission as a trigger to get the string from the text box and set it as the label value,
I was able to tabulate with Google Analytics Behavior->Events.
However, if it is currently entered with a full-width or half-width space, such as "hoge fuga piyo",
They are collectively recognized as a single character string.
Instead, I want each word to be counted once.
If i just divide the string into spaces and put it into an array, you can do it with the following code,
I don't know how to send multiple tracking information based on this array.
var keyword = 'hoge fuga piyo'; var splitKeyword = keyword.split (/ |) / // ["hoge", "fuga", "piyo"]
Thanks for your professor if you have any knowledge.
Answer # 1
You can do it with a for statement
If you have done so far, you have a rest.
You can get each keyword with a for statement and hit the GA event each time.
var keyword = 'hoge fuga piyo'; var splitKeyword = keyword.split (/ |) / // ["hoge", "fuga", "piyo"] // Get array length (number) var keyword_length = splitKeyword.length; // For individual keyword acquisition for (let i = 0;i
* The above JS has not been tested
Because the description is different depending on the version of GA you are using (originally read JS), please refer to the following.
- advanced sql search method
- search - method ~ does not exist
- vba - i want to search for the character string entered in the user form and paste the cell