Closed przybang closed 8 years ago
This project simply lets you use php-ga-measurement-protocol in Laravel. So any issues can only be resolved by them. If there's a problem from this package's end, then I would be happy to look into it. Just thought I'd let you know why I asked to create the issue in that repo.
Greatly appreciated. I’ll let you know if I need you to dive into anything!
Paul
Paul Przyborski Senior Application Developer, Earth Observatory Group
NASA GSFC, Code 613 Greenbelt, MD 20771 Phone: 301-614-6127 http://www.ssaihq.com
http://earthobservatory.nasa.gov http://neo.sci.gsfc.nasa.gov http://eonet.sci.gsfc.nasa.gov http://visibleearth.nasa.gov
Twitter http://twitter.com/NASA_EO/ Facebook http://www.facebook.com/NASAEarthObservatory
On Nov 22, 2016, at 1:33 PM, Syed Irfaq R. ⚡️ notifications@github.com<mailto:notifications@github.com> wrote:
This project simply lets you use php-ga-measurement-protocolhttps://github.com/theiconic/php-ga-measurement-protocol in Laravel. So any issues can only be resolved by them. If there's a problem from this package's end, then I would be happy to look into it. Just thought I'd let you know why I asked to create the issue in that repo.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/irazasyed/laravel-gamp/issues/13#issuecomment-262325283, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAch1QBJcAHD0NktD8sz6f0SEur7W9-Xks5rAzWJgaJpZM4K5kdD.
Actually, Can you post your code (Ofc redact your tracking id and other sensitive info -- if any)?
Maybe we could debug this and fix any issues we come across and perhaps open a PR with the main repo. It's weird it used to work and later it stopped, API changes?
And do you use Async requests? Could be related to the other issue that was earlier reported too. I wasn't able to look into it, but if this is indeed the problem related to Async, then it needs to be fixed. So let me know. Thanks!
My code is fairly straight forward. Because I use it in multiple places, I just built it as a function in my controller:
public function sendAnalytics($url)
{
$gamp = GAMP::setClientId( '123456' );
$gamp->setHitType('pageview');
$gamp->setDocumentTitle('API Request');
$gamp->setDocumentPath($url);
$gamp->sendPageview();
}
The HitType is an attempt to get things to appear. I just fired that off today, so I don't have a real result yet.
The bit that calls the function:
// record the request using google analytics
$url = $request->path();
$this->sendAnalytics($url);
The include is at the top of the controller file:
use Irazasyed\LaravelGAMP\Facades\GAMP;
I am not, at this moment, using the Async option.
Great. Can you try Validating hits and please post the response?
I tried both GAMP and PHP-GA methods, and I get the same result:
BadMethodCallException in Analytics.php line 808: Method getDebugResponse not defined for Analytics class
public function sendAnalytics($url)
{
$gamp = GAMP::setClientId( '123456' );
$gamp->setHitType('pageview');
$gamp->setDocumentTitle('API Request');
$gamp->setDocumentPath($url);
$gamp->setDebug(true);
$gamp->sendPageview();
$debugResponse = $gamp->getDebugResponse();
print_r($debugResponse);
exit;
}
public function sendAnalytics($url)
{
$analytics = new Analytics();
$analytics->setClientId( '123456' );
$analytics->setTrackingId('UA-xxxxxx-1');
$analytics->setProtocolVersion('1');
$analytics->setHitType('pageview');
$analytics->setDocumentTitle('API Request');
$analytics->setDocumentPath($url);
$analytics->setDebug(true);
$analytics->sendPageview();
$debugResponse = $analytics->getDebugResponse();
print_r($debugResponse);
exit;
}
Can you verify you have v2.2.0 of the PHP-GA? Because those methods were added since 2.2.
Looks like I should be okay there. composer show gives me:
theiconic/php-ga-measurement-protocol v2.4.0 Send data to Google Analytics from the server using PHP. This library fully implemen...
No need to bend over backwards. I have a feeling your package isn't my issue.
Just noticed, your code is wrong. Should be this:
...
$gamp = GAMP::setClientId( '123456' );
$gamp->setHitType('pageview');
$gamp->setDocumentTitle('API Request');
$gamp->setDocumentPath($url);
$gamp->setDebug(true);
$response = $gamp->sendPageview();
$debugResponse = $response->getDebugResponse(); // This method is in AnalyticsResponse.
...
Let me just wipe this egg from my face....
Array
(
[hitParsingResult] => Array
(
[0] => Array
(
[valid] => 1
[parserMessage] => Array
(
)
[hit] => /debug/collect?v=1&tid=UA-xxxxxxx-1&cid=123456&t=pageview&dt=API+Request&dp=api%2Fv2.1%2Fevents
)
)
[parserMessage] => Array
(
[0] => Array
(
[messageType] => INFO
[description] => Found 1 hit in the request.
)
)
)
Ok. So I just tested your code with different settings and it seems to be working fine.
Real-time it's instant, but GA takes some time before the data is reflected in other areas of the dashboard. You can verify with different configs and client ids in Audience -> User Explorer but please allow several mins before checking there. It's quite slow.
Also, Make sure the date is properly updated to use today's date (Just in case!).
I will do all of these things. Your testing seems to net the same result as mine, but I have made several changes today. I'll keep an eye on things and see if anything changes. Feel free to close this, as I think it's very unlikely my problem is related to your work. Thanks again!
Alright, Cool.
No problem. Feel free to open an issue ticket if you face any problems. Happy to help :)
I am using this to track hits to pages that generate JSON output (ie, http://eonet.sci.gsfc.nasa.gov/api/v2.1/events). Everything was working until October 10th, and then it stopped recording page hits. I can still see them in realtime, but not in the archive.