Google Analytics Events and Tracking User-Entered Searches

This forum is for all Flare issues related to the HTML5, WebHelp, WebHelp Plus, and Adobe Air Targets

Re: Google Analytics Events and Tracking User-Entered Search

Postby Dave Lee on Sat May 07, 2016 2:49 am

Liv_W wrote:I am using the HTML 5 top nav skin, I just inserted the script into the master pages' bodies using Flare's Insert > Script and reloaded it. Is there a delay? I don't see results in Real Time yet?


There are two scripts - have you included both?

The script from Google Analytics needs to be placed before my script (to record the search terms).


Also, presumably you are testing this from a live website where you know Google Analytics already works?
Dave Lee
Master Propellus Maximus
 
Posts: 5193
Joined: Mon Mar 05, 2007 8:33 am
Location: UK

Re: Google Analytics Events and Tracking User-Entered Search

Postby Liv_W on Tue May 10, 2016 11:37 am

I have Google Analytics up and running and I see myself in there in real time. It's the search that I am struggling with. As I wrote before, I have tried multiple versions of this with the script in different spots. Below is the full topic page. Any thoughts on what I am missing would be appreciated.
Thanks,
Liv
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="7" MadCap:lastHeight="266" MadCap:lastWidth="1179">
    <head>
        <meta charset="utf-8" />
        <meta name="description" content="" />
        <meta name="author" content="" /><title></title>
        <link href="../Stylesheets/MainStyles.css" rel="stylesheet" type="text/css" />
        <script>
         (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
         (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
         m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
         })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

         ga('create', 'UA-77382901-1', 'auto');
         ga('send', 'pageview');
         
         
      </script>
    </head>
    <body>
        <div class="content">
            <div id="contentBody">
                <div class="row collapse">
                    <div class="sideContent">
                        <div class="clearfix">
                            <MadCap:topicToolbarProxy />
                        </div>
                    </div>
                    <MadCap:breadcrumbsProxy />
                    <MadCap:bodyProxy />
                    <p>&#160;</p>
                    <p>&#160;</p>
                    <p class="feedback">Did you find this topic helpful ? Do you have suggestions ? We'd love your <script type="text/javascript">/*<![CDATA[*/var email=('liv.wessel@qvidian.com');
var subject = "Feedback from Topic: " + document.title;
document.write('<a href="mailto:' + email +
'?subject=' +subject+ '">' + 'feedback' + '<'+'/a>');
/*]]>*/</script>!</p>
                    <p>
                        <script type="text/javascript">/*<![CDATA[*/   $(document).ready(function(){
     
         /* FLARE SEARCH BOXES */
         /* add event handler for when search button is clicked */
         $('div.search-submit').click(function(){
         /* get search term from input box (input.search-field), which related to -this- at parent sibling level */
         var searchterm = $(this).parent().siblings('.search-field').val();
         ga('send', 'event', 'Search', 'SearchFor', searchterm);
         });

         /* add event handler for when press Enter (key 13) in search box  */
         $('input.search-field').keypress(function(event) {
         if (event.keyCode == 13) {
         /* get search term from -this- input box (input.search-field) */
         var searchterm = $(this).val();
         ga('send', 'event', 'Search', 'SearchFor', searchterm);
         }
         });/*]]>*/</script>
                    </p>
                </div>
            </div>
        </div>
    </body>
</html>
Liv_W
Propeller Head
 
Posts: 17
Joined: Thu Dec 19, 2013 1:16 pm
Location: Cincinnati, OH

Re: Google Analytics Events and Tracking User-Entered Search

Postby Dave Lee on Wed May 11, 2016 12:05 am

Not sure - it worked for me, and at least one other person.

However, that solution wasn't my preferred method, and isn't what I'm using myself.
I'm tracking searches from the search results page, as mentioned here: viewtopic.php?f=9&t=18356&start=25#p119605
Dave Lee
Master Propellus Maximus
 
Posts: 5193
Joined: Mon Mar 05, 2007 8:33 am
Location: UK

Re: Google Analytics Events and Tracking User-Entered Search

Postby doc_guy on Thu May 19, 2016 9:27 am

So I've been poking at this for the last week or so. I think I've found a solution that works for us. Maybe somebody who knows more can tell me why this is a bad solution...

I went to the Admin page, and clicked View Settings.

Image

Then I set my search parameter to be "Highlight".

Image

And I'm getting results:

Image

And I can even see what page they were on when they searched:

Image

Am I missing anything by not going to the javascript route identified earlier in this thread?
User avatar
doc_guy
Propellus Maximus
 
Posts: 1843
Joined: Tue Nov 28, 2006 11:18 am
Location: Crossroads of the West

Re: Google Analytics Events and Tracking User-Entered Search

Postby Liv_W on Fri May 20, 2016 9:05 am

Thanks. I hope that works; it's so much simpler. I tried this before I posted here, except that I used "search" as the parameters and didn't get anything. I Just tried it with "highlight." Did it take a awhile for you to get the results or was it instant? It looks like you are looking at the Site Search > Overview Page, is that correct?
Thanks,
Liv
Liv_W
Propeller Head
 
Posts: 17
Joined: Thu Dec 19, 2013 1:16 pm
Location: Cincinnati, OH

Re: Google Analytics Events and Tracking User-Entered Search

Postby doc_guy on Fri May 20, 2016 9:12 am

Yes and yes. Make sure you change your date to include today (it doesn't include today by default). I see my info usually within an hour or so.
User avatar
doc_guy
Propellus Maximus
 
Posts: 1843
Joined: Tue Nov 28, 2006 11:18 am
Location: Crossroads of the West

Re: Google Analytics Events and Tracking User-Entered Search

Postby Liv_W on Fri May 20, 2016 9:49 am

It worked! :D You made my day. Thank you so much.
Liv
Liv_W
Propeller Head
 
Posts: 17
Joined: Thu Dec 19, 2013 1:16 pm
Location: Cincinnati, OH

Re: Google Analytics Events and Tracking User-Entered Search

Postby mikey_mack on Fri Sep 02, 2016 7:09 am

This worked perfectly for me! I have my Flare output integrated into our LMS, and I'm able to track searches now. However, I'm unable to get zero-result search terms pulled up. Has anyone been able to figure that out?
mikey_mack
Jr. Propeller Head
 
Posts: 3
Joined: Fri Sep 02, 2016 5:57 am

Re: Google Analytics Events and Tracking User-Entered Search

Postby flicstar on Sun Mar 26, 2017 7:53 pm

Thanks for this code. Can you tell me if it tracks zero search results? That is, search terms that return zero results - so that you can improve your content accordingly.
flicstar
Jr. Propeller Head
 
Posts: 1
Joined: Mon Apr 18, 2016 9:39 pm

Re: Google Analytics Events and Tracking User-Entered Search

Postby Psider on Sun Jun 03, 2018 9:39 pm

I could be wrong, but I think @doc_guy 's method of adding highlight in the GA Admin query parameters won't log the search until a search result is clicked? That is :
1. type something in the search bar.
2. press search.
3. click search result link
4. google logs the search term.

Whereas what we want is for the search to be logged at step 2?
Psider
Sr. Propeller Head
 
Posts: 406
Joined: Wed Jul 06, 2011 1:32 am

Re: Google Analytics Events and Tracking User-Entered Search

Postby Dave Lee on Mon Jun 04, 2018 12:13 am

Psider wrote:I could be wrong, but I think @doc_guy 's method of adding highlight in the GA Admin query parameters won't log the search until a search result is clicked? That is :
1. type something in the search bar.
2. press search.
3. click search result link
4. google logs the search term.

Whereas what we want is for the search to be logged at step 2?


When you set up Site Search in GA, you could record the "q" parameter instead of "Highlight".
I think that should record all the initial search terms, although at the expense of knowing whether people clicked on a result.

Alternatively, you could also record the search terms as events - as discussed earlier in this same post:
viewtopic.php?f=9&t=18356&start=25#p119638
Dave Lee
Master Propellus Maximus
 
Posts: 5193
Joined: Mon Mar 05, 2007 8:33 am
Location: UK

Previous

Return to Web-based Outputs

Who is online

Users browsing this forum: Bing [Bot] and 4 guests