If you look at the code in that HTML Drag and Drop sample, do you see where you get a Point in document coordinates from the call to Diagram.transformViewToDoc?
You could call Diagram.findPartAt with that point to see if the user dropped onto an existing Node. If it finds a Group, you could set the new data object’s containing group key to that group’s key. If it finds a regular Node, you can see if the Node.containingGroup is non-null – if it is, you can use that group’s key.
var point = myDiagram.transformViewToDoc(...);
var containerkey = undefined;
var node = myDiagram.findPartAt(point, false);
if (node instanceof go.Group) {
containerkey = node.data.key;
} else if (node instanceof go.Node) {
var group = node.containingGroup;
if (group !== null) containerkey = group.data.key;
}
myDiagram.startTransaction('new node');
myDiagram.model.addNodeData({
location: point,
text: dragged.textContent,
group: containerkey
});
myDiagram.commitTransaction('new node');