Sie sind nicht angemeldet.

1

Mittwoch, 19. Januar 2022, 18:01

Google Analytics

A client ask me if is possible to track in Google Analytics every single hotspot in the tour.
.
I've tryed an action like this one:

js ga('send', 'event', 'schede', 'a91qm', '91qm' ,'91q', '91qm');



and also

gtag('event', 'a91qm', { 'event_category': 'schede', 'event_label': 'apertura schede', 'value': 'test'});

but with no success


So I ask if someone copuld help me !
Thanks a lot.

Luca

3

Donnerstag, 20. Januar 2022, 09:02

First of al: many thanks for your answer.
I have to say that I am really a novice about this kind of arguments.
So the things that I have done are :
1) in my tour.html file I've added after the <head> section:

Quellcode

1
2
3
4
5
6
7
8
9
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=xxxxxxxxxx "></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){window.dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'xxxxxxxxxx');
</script>

where "xxxxxx" is the Google Analytics ID code
2) in my tour.xml file I've created an action associated to my hotspot with the following code:

Quellcode

1
2
3
4
5
6
7
8
<action name="pippo_clicked">

js gtag('event', 'pippo', {
 'event_category': 'schede',
 'event_label': 'apertura schede',
 'value': '000'
});
</action>

So I really wish to know if I have made some mistake or have to add something other.
Sorry for my very novice question.

4

Donnerstag, 20. Januar 2022, 09:25

you cant call a javascript function with "js gtag" ...
either you use jscall(); or a type="javascript" action :

Quellcode

1
2
3
4
5
6
7
<action name="pippo_clicked" type="javascript">
gtag('event', 'click', { // action
 'event_category': 'hotspot', // category
 'event_label': 'pippo', // label --> i use this as "value"
 'value': 1 // value --> non-negative number only (i don't use this)
});
</action>

Dieser Beitrag wurde bereits 13 mal editiert, zuletzt von »indexofrefraction« (20. Januar 2022, 10:02)


5

Donnerstag, 20. Januar 2022, 11:07

Many thanks again for your kindly answer.
I've done the update to my code.
Since from Analytics I'll see the report of the update tomorrow, I have to wait to tell you if had worked.
thanks
Luca

6

Freitag, 21. Januar 2022, 15:03

Yes it works!!
Fantastic, many thanks for your help!