Joshua, this isn't a standard feature / get function that would be available.
You can however manually access ga object created by the tracking library.
If you for example open console for this webpage and type in:
ga.getAll()[0].a.data.values[':trackingId']
You will receive UA-5620270-1 which is probably the main Analytics Account for Stack Overflow. Similar approach should work in your case as well - and also any other attribute that's accessible:
Screen: http://fii.cz/sbdqevk
Answer from Petr Havlik on Stack OverflowGet account ID from Google Analytics Tracking code on page
Someone else is using our Google Analytics Tracking code number. What do we do?
Cross-domain google analytics tracking on ccTLD?
"Tracking Info" is missing
Is this a GA4 or Universal Analytics property?
GA4 will be set up through the Data Stream whereas the Universal Analytics account should have a “Tracking Code” option. They can both be found in the Admin section under the Property column
More on reddit.comVideos
Joshua, this isn't a standard feature / get function that would be available.
You can however manually access ga object created by the tracking library.
If you for example open console for this webpage and type in:
ga.getAll()[0].a.data.values[':trackingId']
You will receive UA-5620270-1 which is probably the main Analytics Account for Stack Overflow. Similar approach should work in your case as well - and also any other attribute that's accessible:
Screen: http://fii.cz/sbdqevk
If you are prepared to accept a less than elegant solution you could use
function getAccount(_gaq) {
for (i = 0; i < _gaq.length; i++) {
if (_gaq[i][0] == "_setAccount") {
return _gaq[i][1];
}
}
}
_gaq is an array of arrays, the function simply loops through until it finds a subarray where the first element is _setAccount and returns the second element, which is the account number (_gaq.push(['_setAccount', 'UA-XXXXX-X']);).
As you are talking of legacy implementations, there are even older versions of the code so you might need more checks. The oldest version I could find on an active page was:
<script type="text/javascript">
_uacct = "UA-XXXXXXXX-X";
urchinTracker();
</script>
It's quite easy to get the Account Id from there. There is also the synchronous version of the code (sorry, can't find an example right now).
And for the current version look at Petrs answer.
You can exclude the hostname sending data to your profile by setting up an exclude filter.
Alternatively, it might be better if you set up just an include filter for your own hostname to ensure you don't see anything like that in the future.
Google Analytics Filters - you might want to set up a rule/filter to "Include only traffic from the domains equal to" YourDomain.net.
Another commenter mentioned using filters to INCLUDE only your own hostname. I've done this myself and it works great and kills a lot of spam referrals to boot.
One thing to be wary of is that you don't set this on the "all website data" view. Create a new view and name it accordingly to preserve the raw data for the whole site.