9 Replies Latest reply on Jun 22, 2016 3:17 PM by petery

    Google Analytics Outbound Links

    erinclements

      Hi,

      I'm not exactly sure where this question should go, but I can't seem to find a place where it would fit.  We have google analytics integrated in our Jive instance through the admin console.  Our community manager now wants to try and track outbound links.  According to Google Analytics, I need to add a snippet of code to the header, but when I try to do so through the theming tool, it doesn't seem to take.  I am also adding the 'onclick' to the hyperlinks in our header bar, but when i update the theme and look at the source, it doesn't seem to be taking that either. 

       

      Has anyone been successful in tracking outbound links?  We are on Jive 8.02 hosted.  I have Google Analytics activated through System>Settings>Third Party Analytics>Google Analytics and entering our ID there.  I thought about entering the outbound tracking code in the Vendor Code space, but wasn't sure if it would override the Google Analytics integration, or if it would even work being there.  Is there any way to track outbound clicks?  Or are we just out of luck?  Thanks so much!! 

        • Re: Google Analytics Outbound Links
          Scott A Johnson

          Hi Erin,

           

          We have implemented click tracking on a few custom links in our footer through GA.

           

          What we have done is add a snippet of javascript to the Vendor Code space.

           

              $j(document).ready(function () {
                  $j('ul.footer-social > li > a').click(function (e) {
                      var $outLink = $j(this);
                      ga('send', 'event', 'Footer-Social-Icons', 'click', $outLink.attr('data-tracking-label'), {});
                  });
              });
          

           

          Basically, it adds a click binding to the footer social links, then sends a google analytics with a value of a data attribute on the link element.

           

          The ga function is included through the OOB Google Analytics integration which is where we set the GA ID.

           

          Hope that helps,

          Scott

            • Re: Google Analytics Outbound Links
              erinclements

              Thanks Scott!  Do you mind if I 'borrow' this to give it a try for us? 

              • Re: Google Analytics Outbound Links
                Scott A Johnson

                Hi Peter,

                 

                Yes, we've created a custom link block in the footer which displays the social network links as is shown below. The jquery selector in the block above picks up clicks on the anchor tags within this footer-social list, grabs the data-tracking-label attribute value and registers an event with that data.

                 

                 

                <ul class="footer-social">
                    <li>
                        Follow us:
                    </li>
                    <li>
                        <a data-tracking-label="Footer-Facebook" href="https://www.facebook.com/my-account" target="_blank">
                            <span class="custom-icon fb"/>
                        </a>
                    </li>
                    <li>
                        <a data-tracking-label="Footer-Twitter" href="https://twitter.com/my-account" target="_blank">
                            <span class="custom-icon tw"/>
                        </a>
                    </li>
                    ...
                </ul>
                

                 

                 

                Hope this helps,

                Scott

              • Re: Google Analytics Outbound Links
                petery

                I see, if you previously used this feature prior to 8.x, you'll see the tab on 8.x, but since we didn't use the feature now the tab is invisible to us.

                  • Re: Google Analytics Outbound Links
                    Scott A Johnson

                    Super secret system property to re-enable the "legacy" tab...

                     

                    __jive.analytics.thirdParty.legacy.enable = true

                     

                     

                    Shh.... dont let them know I told you.

                      • Re: Google Analytics Outbound Links
                        Scott A Johnson

                        Hi Peter,

                         

                        -- If GA is down/unreachable, your original link would continue to work right?

                        Yes I believe so.

                         

                        -- After I add/change the code in vendor space do I need to restart my Jive instance for it to take effect?   Or would [Save] take effective to the whole site immediately?

                        I believe it's immediate. I don't see a reason why it would require a restart.

                         

                        Scott

                          • Re: Google Analytics Outbound Links
                            petery

                            Confirmed it did show up in View Page Source without needing a restart.

                            I got the event to register in GA, but not the actual link. 

                             

                            What I have in Document HTML view

                            <a class="this_gets_stripped_out_by_Jive" href="http://www.cnn.com/" data-tracking-label="this_gets_stripped_out">CNN</a>

                             

                            What Jive renders:

                            <a class="jive-link-external-small" href="http://www.cnn.com/" rel="nofollow">CNN</a>

                             

                            Need to use href to capture the link.

                             

                            <script>

                            $j(document).ready(function () {

                              $j('.jive-link-external-small').click(function (e) {

                              var $outLink = $j(this);

                              ga('send', 'event', 'External-Links', 'click', $outLink.attr('href'), {});

                              });

                            });

                            </script>