Get hashed site ID via API
The ability to get the hashed siteID from the API, perhaps an addon to the SitesManager module?
In the interim, I've just made something which takes it from the getJavascriptTag function.
public function getHashedSiteId($id)
{
$js_tag = json_decode($this->postRequest('SitesManager.getJavascriptTag', array(
'idSite' => $id
)), true);
return substr($js_tag['value'], strpos($js_tag['value'], 'idsite=') + 7, 8);
}
Thanks @Acen. I will provide this on next release.
Hi @Acen
What API call are you using for query? I remade plugin for new Piwik version and on API calls SitesManager.getJavascriptTag and SitesManager.getImageTrackingCode now is getting code with siteId hashed.
Hey @joubertredrat, I'm using getJavascriptTag and it is indeed getting the hashed ID as part of the entire javascript block.
I'm just needing the hashed ID however to store into an external database and query against later. 👍
Hi @Acen No problem, this was fixed on new version, https://github.com/joubertredrat/Piwik-ProtectTrackID/releases/tag/1.0.0
But see description with attention because you will need make backup of settings.
@Acen explain to me, you need a API call to get only a hashed id from idSite?
Sorry, I really am terrible at following up on Github issues. But you're correct. I just need the hashed ID via an API call so I can store it locally in my own application's database.
For example, something like SitesManager.getHashedID or even perhaps SitesManager.getID
Hi @Acen
I will see if is possible to add new method calls on API for plugin.
Thanks @Acen for reporting this.
This is such an important feature that is missing when sites are configured with Protect TrackID.
SiteID should be available as suggested "SitesManager.getHashedID".
@joubertredrat , request you to prioritize this.
The main purpose or the use-case any one would look for is getting the Protect TrackID for a site that is dynamically added using "SitesManager.addSite". It could be an API that would add the site and return the hashed trackID, like "SitesManager.addSiteGetHashedID"
Thanks a lot.
Hi @Acen and @siva538, sorry for a big delay in my response.
Now the plugin have support to API request by ProtectTrackID.getHashedID method, below an example of request to get hashed id.
Request example
curl --request GET \
--url 'http://matomo.host/?module=API&method=ProtectTrackID.getHashedID&token_auth=my-numeric-token&idSite=1&format=JSON'
Response example
{
"value": "pxE3v5LOJlPpjqDzkNPo"
}