Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting a custom tracking api parameter #153

Closed
mattab opened this issue May 29, 2017 · 6 comments
Closed

Setting a custom tracking api parameter #153

mattab opened this issue May 29, 2017 · 6 comments

Comments

@mattab
Copy link
Member

mattab commented May 29, 2017

Sometimes, new Piwik core releases or even any new plugin may add new parameters to the Tracking API. In those cases it is often not possible to make changes to all necessary SDKs, so the idea is to let user customise the tracking URL.

-> It would be great to have such a method in 4.0.0 beta 👍

Fyi in the PHP SDK we have implemented the following:

    /**
     * Sets a custom tracking parameter. This is useful if you need to send any tracking parameters for a 3rd party
     * plugin that is not shipped with Piwik itself. Please note that custom parameters are cleared after each
     * tracking request.
     *
     * @param string $trackingApiParameter The name of the tracking API parameter, eg 'dimension1'
     * @param string $value Tracking parameter value that shall be sent for this tracking parameter.
     * @return $this
     * @throws Exception
     */
    public function setCustomTrackingParameter($trackingApiParameter, $value)
    {
        $this->customParameters[$trackingApiParameter] = $value;
        return $this;
    }

For example users may want to override the Geo location info of country, region and city of a visitor (see matomo-org/matomo#11563 (comment) for more info how to achieve this without having to set the token_auth)

refs #82 (comment)

@brototyp
Copy link
Member

brototyp commented Jun 3, 2017

I think the best idea would be a combination of the following two features:

  • Add a let customTrackingParameters: [String:String] to the Event object
  • Make the queue(event: ) of the PiwikTracker public

This way one could create a custom Event object, setting all existing parameters. The customTrackingParameters dictionary would then enable setting all the different parameters.

@mattab
Copy link
Member Author

mattab commented Jun 4, 2017

Is your Event related to Piwik Events? http://piwik.org/docs/event-tracking/

maybe it's possible to make it simpler and just have one method like in the PHP tracker, that will set the custom tracking parameter. Similar to 'setResolution', 'setUserId' etc

@brototyp
Copy link
Member

brototyp commented Jun 4, 2017

Events in this SDK are rather "things that should be tracked". So an event could be a view, a download, an exception and so on. Those events are quite atomically. There is barely a situation where one would set any data on the Tracker class directly. In the iOS SDK you create an event and dispatch it via the tracker. There are shortcuts on the Tracker, like track(view: ) but internally they just create an Event and then dispatch it via itself.

@brototyp brototyp modified the milestones: 4.2.0, 4.1.0 Jul 15, 2017
@mattab
Copy link
Member Author

mattab commented Sep 22, 2017

Hi @brototyp do you think it would be possible to prioritise this little feature? It would be awesome to have as it would let anyone track the not-yet-supported-by-SDK features, such as Media Analytics requests: https://developer.piwik.org/guides/media-analytics/custom-player#media-analytics-http-tracking-api-reference
Thanks for consideration!

@brototyp
Copy link
Member

Hi @mattab, yes I will try to do that. Thanks for nudging. It takes a while to figure out this feature without exposing to much internals, and thus have to guarantee that they don't change soon.

@brototyp
Copy link
Member

brototyp commented Oct 8, 2017

Good news! It just got merged to the development branch and will be part of the next release. Please check this part of the readme for more details.

@brototyp brototyp closed this as completed Oct 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants