Sie sind nicht angemeldet.

1

Freitag, 5. Januar 2018, 23:53

Display Scene and title in Google Analytics

Hi,

I use this piece of code in my index.html (previously made available here on the forum)

Quellcode

1
2
3
4
5
6
7
8
<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  ga('create', 'UA-000000000-1', 'auto');
  ga('send', 'pageview');
</script>


and add this to my xml file

Quellcode

1
<events onxmlcomplete=" js(ga('send','pageview', get(xml.scene) ) );" />


On Google Real-Time the Active page is
/scene_005

As I've got several individual tours to track which are all in a folder called VT (then in their own folder titled 004, 005, 006, 007 etc.) I'd like to display the title and then the scene.

I changed it to
<events onxmlcomplete=" js(ga('send','pageview', get(xml.title.scene) ) );" />

then on Google Real-Time the Active page is this below but no scene.
/vt/004/


Tried get(xml.scene.title) but still get
/vt/004/


I think I'm missing something really simple here so was hoping anyone could point me in the right direction please?

Also is there a way to track hotspot clicks also that are inside the scene as each one generally has 4-5 hotspots.......... or am I pushing it *smile*


Thanks for your time,

Andrew

2

Samstag, 6. Januar 2018, 10:10

untested, but maybe try with get(scene[get(xml.scene)].name);

and you should use a name for your event, i think:
<events name="google_watches" onxmlcomplete="js(ga('send', 'pageview', calc('SCENE=' + scene[get(xml.scene)].name)));" />

for hotspots you can add (or add to) an existing onclick event, of course
txtadd(hotspot[myhotspot].onclick, "js(ga('send', 'pageview', calc('HOTSPOT=' + name)));");

the latter i would implement as an action which is called by each scenes onxmlcomplete event
in the action you must loop through the scenes hotspots and add the onclick event to each of them

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »indexofrefraction« (6. Januar 2018, 10:22)


3

Sonntag, 7. Januar 2018, 00:32

Thanks for the reply and code Index. Appreciate it.

I tried but no luck. As soon as I mess with it the result defaults to /vt/004/ and nothing afterfor any scenes viewed. I tried it with the event having a name and without.


One solution I did work out yesterday was to add the tour number to the scene name(via find and replace in Notepad ++) so it would look like this

<scene name="scene_004_035"

then when you view Google Real-Time you see this

Active Page
1./scene_004_035



That would at least narrow it down to the 004 tour but it's still hard to identify what 035 is showing as it's just a number. That info is in the title of the scene which is what I'm trying to display at the end

title="B52 Cockpit pilot seat"



I tried the hotspot code to an existing onclick event but get the old xml parsing failed! error message

Element type "hotspot" must be followed by either attribute specifications, ">" or "/>".

Quellcode

1
<hotspot name="h1" title="" style="info_hotspot"  zoom="false" ath="12.133" atv="8.031" onclick="Galereya(Set_004_005_1); txtadd(hotspot[myhotspot].onclick, "js(ga('send', 'pageview', calc('HOTSPOT=' + name)));"); " />



I'll keep plugging away


Cheers,

Andrew

4

Sonntag, 7. Januar 2018, 09:51

instead of events onxmlcomplete maybe try to use your scene onstart event
<scene name="scene_004_035" ... onstart="js(ga('send', 'pageview', calc('SCENE=' + scene[get(xml.scene)].name)));" >
...
</scene>

in your hotspots you already have an onclick event, so you dont need to txtadd.
<hotspot ... onclick="Galereya(Set_004_005_1); js(ga('send', 'pageview', calc('HOTSPOT=' + name)));" />

note: in properties (onstart, onclick, etc) you cannot use " again
onclick="debug('hello')" works, but onclick="debug("hello")" does not!

maybe you should post a link to your tour, that would help
best index

5

Freitag, 12. Januar 2018, 18:45

Hi,

Zitat

I tried the hotspot code to an existing onclick event but get the old xml parsing failed! error message
Element type "hotspot" must be followed by either attribute specifications, ">" or "/>".

Better put your onclick code into a separate <action> - this way you more possibilities when using several double characters in a string.

Best regards,
Klaus