Pass in node ID to javascript call

Q&A about the latest versions
Post Reply
LProbert
Posts: 92
Joined: Thu May 21, 2020 11:53 am

I am running some javascript through a getURL action on my node hotspot skin element, and would like to pass in the name of the target node. Is this going to work?

Code: Select all

dataLayer.push({'event': 'tourNodeSelected','tourName':$(hu)});
Do you process the string in this field with the $(hu) ???
LProbert
Posts: 92
Joined: Thu May 21, 2020 11:53 am

It doesn't look like it does work. I get this error:

Code: Select all

Uncaught ReferenceError: $ is not defined
How would I do this to pass meaningful information about the tour selection to Google Tag Manager?
christoph
Gnome
Posts: 108
Joined: Mon Aug 20, 2012 3:01 pm

Placeholders cannot be used in Javascript code.
But you can get the information in other ways.
In your case (if you want to access hotspot information from within a hotspot template) you would use:

Code: Select all

javascript: dataLayer.push({'event': 'tourNodeSelected','tourName':me.hotspot.url});
Or if you wanted to access userdata of a node, use the player function - getNodeUserdata(), like:

Code: Select all

javascript: alert(player.getNodeUserdata().title);
Regards,
Christoph
LProbert
Posts: 92
Joined: Thu May 21, 2020 11:53 am

I ended up using

Code: Select all

pano.getNodeTitle()
But it's interesting how you suggested doing it. What is this 'me' object? Do you have more to the Javascript API documented anywhere?
Post Reply