Google Analytics Component

GGail
Posts: 7
Joined: Thu Feb 27, 2020 11:00 am

Thu Nov 26, 2020 1:57 pm

Hi, about the user that was asking how to get dynamically the hotspot description in the action so as to send it to Google Analytics, I managed to do it by traversing the DOM to the tooltip element:

Code: Select all

javascript:gtag('event', 'Hotspot Clickeado', {
  'event_category': player.getVariableValue('UA_category'),
  'event_label': $(this).parent().find('.ggskin_text ').children().first().html()
});

I'm sure there is a better way to get this piece of information, but I couldn't find it easily in the documentation (https://ggnome.com/doc/javascript-api/)
GGail
Posts: 7
Joined: Thu Feb 27, 2020 11:00 am

Thu Nov 26, 2020 2:17 pm

A safer way to get the node root element would be to search the closest .ggskin_hotspot parent

Code: Select all

javascript:var label=$(this).closest('.ggskin_hotspot ').find('.ggskin_text ').children().first().html();
console.log('label:'+label);gtag('event', 'Hotspot Clickeado', {
  'event_category': player.getVariableValue('UA_category'),
  'event_label': label
});
Moritz.s
Posts: 4
Joined: Tue Jun 16, 2020 2:58 pm

Wed Dec 09, 2020 11:07 am

Hi,

Nice component! It fires up all my events on my local preview but I don't get anything in my analytics account from the live website uploaded on my webspace. Any ideas?

Bitdefender anti tracker :D
User avatar
Hopki
Gnome
Posts: 12514
Joined: Thu Jan 10, 2008 3:16 pm
Location: Layer de la Haye, Essex UK
Contact:

Wed Dec 09, 2020 9:00 pm

Hi,
If it works locally but not once uploaded then something is stopping it sending the information.
Do you have any security plugins in your browser?
Regards,
Garden Gnome Support
If you send an e-mail to support please send a link to the forum post for reference.
support@ggnome.com
https://ggnome.com/wiki/documentation/
User avatar
JRumball
Posts: 66
Joined: Wed Jun 11, 2014 10:45 am

Mon Jan 18, 2021 1:07 pm

I have implement the GA component in my sites for a recent project and I am seeing event data in my GA 4 dashboard, but I am not seeing pano names at all.

I have the following type of action script in place on important buttons in my skin, changing only the event name:

Code: Select all

javascript:gtag('event', 'Photo Button', {
  'event_category': player.getVariableValue('UA_category'),
  'event_label': player.userdata.title
});
In my realtime GA console, this is the type of thing I see:
pano2vr ga data.JPG
pano2vr ga data.JPG (25.42 KiB) Viewed 3505 times
Any idea what I need to change to be able to view user data titles in the GA 4 console?

Thanks in advance.

John
User avatar
Hopki
Gnome
Posts: 12514
Joined: Thu Jan 10, 2008 3:16 pm
Location: Layer de la Haye, Essex UK
Contact:

Mon Jan 18, 2021 1:27 pm

Hi John,
First question would be do you have names entered in the user data titles of each node?
Regards,
Garden Gnome Support
If you send an e-mail to support please send a link to the forum post for reference.
support@ggnome.com
https://ggnome.com/wiki/documentation/
User avatar
JRumball
Posts: 66
Joined: Wed Jun 11, 2014 10:45 am

Mon Jan 18, 2021 1:52 pm

Yes I sure do.

Actually, I did a bit more digging inside the GA console abd discovered that the udt is indeed being captured, but just not been by displayed in this new version of the GA console.

So I think the GA component is working fine... I just need to learn how to extract the info I’m looking for from GA.

Thanks Martin.
User avatar
Isaac Brown
Posts: 77
Joined: Tue Jun 13, 2017 12:55 pm
Location: Australia

Thu Nov 18, 2021 7:45 am

Hey Hopki,
When I do this:

'event_label': player.hotspot.title

In Google Analytics I get a (not set) value in the Event Label column...

Im not sure what I am doing wrong?
Isaac / IBCreative
Marco360
Posts: 20
Joined: Wed Feb 19, 2020 1:02 pm

Mon Mar 28, 2022 10:59 am

JRumball wrote:
Mon Jan 18, 2021 1:52 pm
Yes I sure do.

Actually, I did a bit more digging inside the GA console abd discovered that the udt is indeed being captured, but just not been by displayed in this new version of the GA console.

So I think the GA component is working fine... I just need to learn how to extract the info I’m looking for from GA.

Thanks Martin.
you can click on "Note Change" for more information on this event. Further I guess the "Button click" event is on page2 as you are only seeing the 6 most events (little arrows on the bottom)
LaurentVR
Posts: 41
Joined: Mon May 25, 2020 11:21 am

Fri Apr 22, 2022 10:52 am

Marco360 wrote:
Thu Jun 04, 2020 2:27 pm
Hey All,

fantastic to get GA now in the tours.

Due to DSGVO (German equivalent to GDPR) you'll need to get the opt-in from visitors to use GA, or am I wrong?
Therefore I put the consent-cookie-request before (linked in index.html) and changed the component-text to only load the gtag in case of opt-in. works amazing (feel free to ask if you're interested), BUT
due to 3rd-Party-Cookie-policies no tour fires events when hosted in iFrames. Therefore I'm trying to find out: how to you link the tour (if you offer hosting (keyword: cross-domain...)?

Thanks
Marco
Hello Marco,

I'm interested in the consent cookie request you have to load or not the gtag. Can you tell me more ?

Thanks

Laurent
Marco360
Posts: 20
Joined: Wed Feb 19, 2020 1:02 pm

Fri Apr 22, 2022 11:21 am

LaurentVR wrote:
Fri Apr 22, 2022 10:52 am
Hello Marco,

I'm interested in the consent cookie request you have to load or not the gtag. Can you tell me more ?

Thanks

Laurent
Hey Laurent,

unfortunately the time made my comment incorrect now, as Austria & France declared the usage of Google Analytics as not compliant with the GDPR. It was stated that Netherlands will follow, so that it is to be expected that due to missing/failed "Save Harbour" the usage in whole EU is not GDPR-conform - even with opt-in user-consent (as EU-citizens data is not enough protected in US).

Nevertheless: my Opt-in is following this scheme (2 major changes):
I used the open Source OSANO-Cookie Consent tool (www.osano.com/cookieconsent/download) by adding this lines into a separat copy of the normal.ggt.

Code: Select all

	
	<link rel="stylesheet" type="text/css" href="assets/cookieconsent.min.css" />
	<script src="assets/cookieconsent.min.js" data-cfasync="false"></script>
The files in assets/ are downloaded from "https://cdn.jsdelivr.net/npm/cookieconsent@3/build/" (you could also link to there but I do not like to use to many sources).

The 2nd change is within the GA-component from GGNome: in skin-editor select the init_GA (GA-component) and go to TEXT in preferences and replaced everything with:

Code: Select all

javascript:"Please set your Google tracking ID";
var ua_id=player.getVariableValue('UA_ID');


// Google Analytics Function for embedding tracking code
 
// Google Analytics Cookie Domain & Path (needed for clearing cookies – have look in the inspector to get the values needed)
var $tracking_cookie_domain = ".yourdomain.fr";
var $tracking_cookie_path = "/";
 
function embedTrackingCode(){
    // add <script> to head
	if (!window.dataLayer) {
	  window.dataLayer = [];
	  let script = document.createElement('script');
	  script.async=1;
	  script.src = 'https://www.googletagmanager.com/gtag/js?id='+ua_id;
	  document.head.appendChild(script);
	}


	function gtag() { window.dataLayer.push(arguments);}
	window.gtag=gtag;
	gtag('js', new Date());
	gtag('config', ua_id, { 'anonymize_ip': true });
}
 
function deleteGACookies(){
     
    // because the gtag cookie uses the tracking id with "-" replaced though "_"
    // we have to do this string manipulation too
    var $gtag_cookie = "_gat_gtag_"+ua_id.replace(/-/g, "_");
 
    clearCookie('_ga',$tracking_cookie_domain,$tracking_cookie_path);
    clearCookie('_gid',$tracking_cookie_domain,$tracking_cookie_path);
    clearCookie('_gat',$tracking_cookie_domain,$tracking_cookie_path);
    clearCookie($gtag_cookie,$tracking_cookie_domain,$tracking_cookie_path);
    location.reload();
}
 
 
// Insites Cookie Consent with Opt-IN for MATOMO tracking Cookie
// Source: https://cookieconsent.insites.com/documentation/disabling-cookies/
window.addEventListener("load", function () {
    window.cookieconsent.initialise({
        "palette": {
    "popup": {
      "background": "#edeff5",
      "text": "#838391"
    },
    "button": {
      "background": "#4b81e8"
            }
        },
        "cookie": { 
            "expiryDays": 1 
         },
        "theme": "edgeless",
        "type": "opt-in",
        "content": {
            "message": "Zur Optimierung dieser Virtuellen Tour möchten wir Google Analytics anonym verwenden.",
            "allow": "Einverstanden",
            "deny": "Ablehnen",
            "link": "Datenschutzerklärung",
            "href": "https://yourdomain.fr/GDPR.html",
            "policy": 'Cookie Einstellungen'
        },
        onPopupOpen: function () {
            document.body.classList.add("cookieconsent-banner-opened");
        },
        onPopupClose: function () {
            document.body.classList.remove("cookieconsent-banner-opened");
        },
        onInitialise: function (status) {
            var type = this.options.type;
            var didConsent = this.hasConsented();
            if (type == 'opt-in' && didConsent) {
                // enable cookies
                embedTrackingCode();
    
            }
            if (type == 'opt-out' && !didConsent) {
                // disable cookies
            }
        },
        onStatusChange: function (status, chosenBefore) {
            var type = this.options.type;
            var didConsent = this.hasConsented();
            if (type == 'opt-in' && didConsent) {
                // enable cookies
                embedTrackingCode();
            }
            if (type == 'opt-in' && !didConsent) {
                // disable cookies
                deleteGACookies();
            }
            if (type == 'opt-out' && !didConsent) {
                // disable cookies
                deleteGACookies();
            }
        },
        onRevokeChoice: function () {
            var type = this.options.type;
            if (type == 'opt-in') {
                // disable cookies
                 
            }
            if (type == 'opt-out') {
                // enable cookies
                embedTrackingCode();
            }
        },
 
    })
});
 
// Function for deleting Cookies (such as that ones from Google Analytics)
// Source: https://blog.tcs.de/delete-clear-google-analytics-cookies-with-javascript/
function clearCookie(d,b,c){try{if(function(h){var e=document.cookie.split(";"),a="",f="",g="";for(i=0;i<e.length;i++){a=e[i].split("=");f=a[0].replace(/^\s+|\s+$/g,"");if(f==h){if(a.length>1)g=unescape(a[1].replace(/^\s+|\s+$/g,""));return g}}return null}(d)){b=b||document.domain;c=c||"/";document.cookie=d+"=; expires="+new Date+"; domain="+b+"; path="+c}}catch(j){}};
 
 
// function for triggering a click on the cc-revoke button
// wich will show the consent banner again.
// You may use it in a link, such as this example:
// <a href="#" onclick="openCCbanner(); return false;">Cookie Consent</a>
function openCCbanner(){
    var el = document.querySelector('.cc-revoke');
    el.click();
}
I think that's all. (Cookie banner will re-request as it simple reloads the side on decline consent ;) )

Guess there might be smarter ways - but was working ;)
User avatar
Carlos Chegado
Posts: 55
Joined: Wed Feb 14, 2007 7:11 pm

Thu Jun 16, 2022 3:29 am

G'Day ,

I plan to move my Virtual Tour analytics to GA4.

Will this component still work with the new Google Analytics (GA4) or do I need to make any changes to it besides using the new Gtag ID?

Cheers
User avatar
Hopki
Gnome
Posts: 12514
Joined: Thu Jan 10, 2008 3:16 pm
Location: Layer de la Haye, Essex UK
Contact:

Sat Jun 18, 2022 4:27 pm

Hi Carlos,
As far as I know, all works the same.
But I would try it just to make sure.
Regards,
Garden Gnome Support
If you send an e-mail to support please send a link to the forum post for reference.
support@ggnome.com
https://ggnome.com/wiki/documentation/
User avatar
Carlos Chegado
Posts: 55
Joined: Wed Feb 14, 2007 7:11 pm

Mon Jun 20, 2022 11:53 pm

Hi Martin,

Yeah, it sort of works.

I can see certain events being recorded on GA4 but I'm not seeing the node names and VT names associated properly.

Maybe it's just how bad GA4 is compared to UA.

Anyway, it is recording node changes and node clicks, just not seeing what nodes are being clicked for example!

Overall, not as useful as with UA, but maybe it's me not being used to GA4!

Cheers
moxben
Posts: 10
Joined: Tue Oct 06, 2020 3:45 pm

Tue Nov 29, 2022 11:46 am

Hey there,

did someone fix the GA4 issue? I am talking about not being able to see Event Lables etc., as I was used to it in UA.

All the best and thanks in advance,
Benjamin
Post Reply