Closed mikeymeister closed 1 year ago
So I tried replicating this... here are my plugin settings:
...and here's the Twig code:
{% do instantAnalytics.setMeasurementId("G-7DDE6SKB8E") %}
{% do instantAnalytics.setApiSecret('xyz') %}
{% dd instantAnalytics %}
Which outputs:
...so it is changing both properties. Is there something I'm missing here?
I've upgraded to the latest v3 version as I was one behind, just to be sure but am still getting the same results. If I follow your example:
Settings:
Template:
{% do instantAnalytics.setMeasurementId("replacement-key") %}
{% do instantAnalytics.setApiSecret("replacement-secret") %}
{% dd instantAnalytics %}
Result:
My suggestion about the code was just noticing a difference between how the setMeasurementId() and setApiSecret functions were different.
/**
* Set the measurement id.
*
* @param string $measurementId
* @return $this
*/
public function setMeasurementId(string $measurementId): self
{
$service = $this->service();
if (!$service) {
throw new InvalidConfigException('instant-analytics-ga4', 'Unable to create GA4 service object');
}
$service->setMeasurementId($measurementId);
return $this;
}
/**
* Set the API secret.
*
* @param string $apiSecret
* @return $this
*/
public function setApiSecret(string $apiSecret): self
{
$service = $this->service();
if (!$service) {
throw new InvalidConfigException('instant-analytics-ga4', 'Unable to create GA4 service object');
}
return $this;
}
Maybe I am missing something? Happy to provide any more info, and really appreciate your help with this.
Ah I think this is specific to the v3 version, it's an oversight. Thanks for the report!
When following the example from the docs below:
The api secret is not updated.
Looks like the following is missing from
nystudio107\instantanalyticsGa4\ga4\Analytics::setApiSecret
on (approx) line 262.Version: 3.0.0-beta.2