4 Replies Latest reply on Nov 19, 2018 1:47 AM by sscullion

    How to get Analytics in custom Add-On Jive Cloud?

    james1.hicks Novice

      I asked a similar question a few months ago about using google analytics in Jive Cloud. I had meant to ask about using it in custom Jive Hosted Add Ons/Apps.


      With Google Analytics, it seems you need to know the site url in order to track things. Because custom Add Ons are loaded through an iframe and Jive has its own url for those, I'm unsure how to go about getting Analytic information from within the application. We've been using Jive's Analytics API exclusively up until now.




      We are in process of consolidating several custom Add Ons in our Add On list into a single one (so we only upload one add on comprising of several tools). These separate tools in this one Add On will still be accessible individually, through tabs or something similar. We are looking to get analytics for each tool visit as a unique visit so it imitates how jive looks at Add On analytics currently. We want to keep track of user, session, and tool name/id (to keep track of tool). At first glance, setting each tab to have its own path ('/path') and having GA look at that seems the right direction. But I'm unsure what GA is looking at, jive's app url or the instance url ('apps/...').


      I'm also fairly new to GA and I'm having difficulty imagining how analytics would work within an iframe and a single page application.


      Once we find this out, this opens up the possibility of doing more analytics inside of all our add ons.



      Anyone with experience doing analytics on a Custom Jive Hosted Add On? Any similar to this use case? Experience with Google Analytics in a Single Page App? In iframes?


      I am more than willing to clarify if anything is fuzzy! We have not started development of this yet, so figuring this out now will be amazing for this project.



      Thank you,


        • Re: How to get Analytics in custom Add-On Jive Cloud?
          sscullion Advanced

          Hi James,


          Good news, yes, this can be done!


          I've done a fair bit of this, both including Google Analytics (GA) and Google Tag Manager (GTM) in add-ons and HTML tiles.


          Essentially you'll need to include the GA code snippet in the pages rendered by your app. I'd recommend taking into account somehow in your add-on config setting up the correct tracking ID for GA. You'll want different GA properties for dev/test and prod.


          This will give you pageviews (hits) in GA for the pages rendered by your app. You may need to consider cross-domain tracking depending on what you're looking to capture around the context of your app iframes within your Jive instance.


          You mention you have "tabs" and single page apps, in which case here you'd be looking to trigger additional "virtual pageviews" and events into GA to capture. You may want to consider sending additional hits or events to GA using the documented JS provided by Google.


          I mentioned GTM early on, this is a great way of taking out the pageview and event tracking logic and code from you app. You'd add the GTM JS snippet instead of the GA snippet, and from there it's working in GTM to add GA and set up the pageview and event tracking you're looking for.


          I hope that helps, keep me posted on how you get on!



            • Re: How to get Analytics in custom Add-On Jive Cloud?
              james1.hicks Novice

              Hey Simon,


              So I am attempting to do this currently to test it out, nothing complicated just a simple userID. And I am having difficulty getting a custom dimension to be sent to GA. Below is what I have right now. I went off the most recent walkthrough on GA site. They use gtag instead of the older ga.


              <script async src="https://www.googletagmanager.com/gtag/js?id=GA_ID"></script>
              var userID = 12345;
                window.dataLayer = window.dataLayer || [];
                function gtag(){window.dataLayer.push(arguments);}
                gtag('js', new Date());
                gtag('config', 'GA_ID');
              // // Maps 'dimension2' to 'age'.
              gtag('config', 'GA_ID', {
                 'custom_map': {'dimension1': 'Custom User ID'}
              gtag('set', 'userID', userID);
              // Sends an event that passes 'age' as a parameter.
              gtag('event', 'sendUser', {"Custom User ID": userID});
              console.log("userID: ", userID)


              I can see that when I am in my Add On, there is 1 active user (me), I can also see that my event has been registered. However, nothing seems to be being sent.


              My custom dimension is named "Custom User ID".


              Any help would be appreciated.


              Thank you,


              • Re: How to get Analytics in custom Add-On Jive Cloud?
                james1.hicks Novice

                I was able to figure this out with y our help thank you.

                1 person found this helpful