Google Analytics issue - site search has no results

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

Google Analytics issue - site search has no results

Postby yeulih on Thu May 31, 2018 2:20 pm

Hello,

I have recently implemented Google Analytics in my HTML5 output. This worked great, as Google Analytics seems to tracking the visits with no issues.

I then implemented the Google Analytics site search functionality, using the instructions from https://mike.kelley.consulting/blog/how ... tml-output . It's been several months and unfortunately, I'm getting nothing when I view the Reports -> Site Search pages.

This is my code:
Code: Select all
      <!-- Global site tag (gtag.js) - Google Analytics -->
      <script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-########-#"></script>
      <script>
         window.dataLayer = window.dataLayer || [];
         function gtag(){dataLayer.push(arguments);}
         gtag('js', new Date());
         gtag('config', 'UA-########-#');
      /* ]]> */</script>


I added the GA script to my master page in the <body> section. From a previous forum topic it was indicated that it would work in either the <head> or the <body> section. (viewtopic.php?f=9&t=30141). Can anyone help diagnose why my site search isn't working? The only thing I can think of so far is that the GA code doesn't show up in my output trigger file (Flare uses default.htm by default), but I'm not sure why this matters as it seems to work for others.

Thanks in advance!
Last edited by yeulih on Thu May 31, 2018 8:53 pm, edited 1 time in total.
yeulih
Jr. Propeller Head
 
Posts: 3
Joined: Thu Feb 22, 2018 12:50 pm

Re: Google Analytics issue - site search has no results

Postby Psider on Thu May 31, 2018 5:44 pm

I think your end script tag is in the wrong place (in the middle of you google script). Delete that whole line and make sure there is a single </script> tag after that gtag(config line.


yeulih wrote:Hello,

I have recently implemented Google Analytics in my HTML5 output. This worked great, as Google Analytics seems to tracking the visits with no issues.

I then implemented the Google Analytics site search functionality, using the instructions from https://mike.kelley.consulting/blog/how ... tml-output . It's been several months and unfortunately, I'm getting nothing when I view the Reports -> Site Search pages.

This is my code:
Code: Select all
      <!-- Global site tag (gtag.js) - Google Analytics -->
      <script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-########-#"></script>
      <script>
         window.dataLayer = window.dataLayer || [];
         function gtag(){dataLayer.push(arguments);}
         gtag('js', new Date());
      /* ]]> */</script>
         gtag('config', 'UA-########-#');


I added the GA script to my master page in the <body> section. From a previous forum topic it was indicated that it would work in either the <head> or the <body> section. (viewtopic.php?f=9&t=30141). Can anyone help diagnose why my site search isn't working? The only thing I can think of so far is that the GA code doesn't show up in my output trigger file (Flare uses default.htm by default), but I'm not sure why this matters as it seems to work for others.

Thanks in advance!
Psider
Sr. Propeller Head
 
Posts: 406
Joined: Wed Jul 06, 2011 1:32 am

Re: Google Analytics issue - site search has no results

Postby yeulih on Thu May 31, 2018 8:53 pm

Oops, I copied it in two parts and accidentally mixed up the order. I will edit the original post to reflect the actual script as it appears in my Flare project.
yeulih
Jr. Propeller Head
 
Posts: 3
Joined: Thu Feb 22, 2018 12:50 pm

Re: Google Analytics issue - site search has no results

Postby Dave Lee on Fri Jun 01, 2018 12:09 am

yeulih wrote: Can anyone help diagnose why my site search isn't working?


You've said that GA is tracking your visits, so there's nothing wrong with the actual GA code.

First, I would double-check that you've set up GA for site search tracking, as described in Mike's blog post.
You need to set Site Search Tracking - On, and enter Highlight as the Query parameter.

Next, what skin are you using?
The site search definitely works for the Top Nav skin (and presumably the new Side Nav), but I don't think it works for the Tripane skin.
Or at least it doesn't work for any of my sites that use Tripane.
Dave Lee
Master Propellus Maximus
 
Posts: 5193
Joined: Mon Mar 05, 2007 8:33 am
Location: UK

Re: Google Analytics issue - site search has no results

Postby yeulih on Fri Jun 01, 2018 1:15 pm

Dave, thanks for the help! I'm indeed using a tripane skin, so that seems to be my issue. I was hoping for something easy, but it looks like that's not going to happen...I suppose that to make this happen I will need to use insert Javascript code.
I came across this forum topic when I was looking for more information on tracking site search: viewtopic.php?f=9&t=18356. Would this method still work?

I updated the code in the above topic to reflect the new gtag usage:
Code: Select all
    $(document).ready(function(){

       $('div.search-submit').click(function(){
          gtag('event','search',{document.getElementById('search-field').value});
       });

       $('input#search-field').keypress(function(event) {
               if (event.keyCode == 13) {
                   gtag('event','search',{document.getElementById('search-field').value});
               }
       });

    });
yeulih
Jr. Propeller Head
 
Posts: 3
Joined: Thu Feb 22, 2018 12:50 pm

Re: Google Analytics issue - site search has no results

Postby Dave Lee on Sun Jun 03, 2018 11:58 pm

yeulih wrote:Dave, thanks for the help! I'm indeed using a tripane skin, so that seems to be my issue. I was hoping for something easy, but it looks like that's not going to happen...I suppose that to make this happen I will need to use insert Javascript code.
I came across this forum topic when I was looking for more information on tracking site search: viewtopic.php?f=9&t=18356. Would this method still work?


Yeah, I'm not sure how to record the "Highlight" parameter with Site Search in a Tripane skin. I assume it doesn't work because the "Highlight" parameter (on the top level page) and the help topic you visit are on separate pages.

The script in that other post records search terms as events (rather than using the Site Search). Provided that you send the event in the correct format using gtag(), then I'd expect it to still work.
Dave Lee
Master Propellus Maximus
 
Posts: 5193
Joined: Mon Mar 05, 2007 8:33 am
Location: UK

Re: Google Analytics issue - site search has no results

Postby Psider on Mon Jun 04, 2018 5:54 pm

So I've been doing some research into tripane and google analytics.

I think the reason the search can't be logged in GA in tripane is that the actual path and search is after a hash/pound sign, which GA throws away.
(This page states that it's thrown away and provides a gtag solution, but I'm not on gtag at the moment. And the images are broken, but you might be able to find them on the wayback machine. And I'm sure there are pages discussing the same or similar solutions.
https://www.beyond.com.au/blog/external ... ag-manager)

e.g
Address bar:
http://my.site.com/index.htm#My_awesome_widget.htm
http://my.site.com/index.htm#My_awesome ... ght=widget

What seems to be logged is the iframe location rather than the "page" location.

e.g
Address bar: http://my.site.com/index.htm#My_awesome ... ght=widget
Logged path: http://my.site.com/My_awesome_widget.htm

You can see both of these in the browser console using location.href and frames.topic.location.href respectively.
('topic' is the name of the content iframe)

I'm not quite sure if GA tracks the frame automagically or if it's something in the Madcap javascript somewhere.

I think Tripane is a form of Single Page Application. The URL changes but the page doesn't actually reload(?). And there's a page for developers about how to develop them for GA: https://developers.google.com/analytics ... plications

But I'm not a developer so I'm not quite sure what would be needed (I'll probably figure it out in a couple of months of mucking around. :p ).

And I wonder if this plugin would solve the issue:
https://github.com/googleanalytics/auto ... tracker.md

Anyway, it doesn't help with the original question, but maybe it'll help someone down the track.
Psider
Sr. Propeller Head
 
Posts: 406
Joined: Wed Jul 06, 2011 1:32 am


Return to Web-based Outputs

Who is online

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