我的代码在php 5之上工作
它实际上是GA库,这是它的github项目。
我克隆了项目theiconic/php-ga-measurement-protocol
由于我是PHP的新手,我不知道在哪里放这个代码,请在这里帮助我这个项目应该通过编码器通过代码安装
{
"require": {
"theiconic/php-ga-measurement-protocol": "^2.0"
}
}
在这一步之后,我需要创建一个文件something.php,我需要把代码放在下面,我在服务器上找到autoload.php时遇到问题,请看下面的代码来理解我在说什么。
<?php
//grab the data that Calendly sent in the webhook and store it in a variable called $objCalendlySubmission...
$objCalendlySubmission = json_decode(file_get_contents('php://input'));
//We've passed the Google client_id in Calendly's placeholder for utm_term. Feel free to pass it differently, this is just an example
if(property_exists($objCalendlySubmission->payload->tracking, 'utm_term') && !empty($objCalendlySubmission->payload->tracking->utm_term)) {
$strPageViewed = 'calendly_conversion.html'; // We use different page names depending on what type of event was scheduled via Calendly
sendGoogleAnalyticsPageView($objCalendlySubmission->payload->tracking->utm_term, $strPageViewed);
}
function sendGoogleAnalyticsPageView($strGAClientId, $strURL) {
require_once '/path_to_composer/composer/vendor/autoload.php'; //loads the PHP library for the "Google Analytics Measurement Protocol” **I dont know where is it located exactly on my xampp server, Please guide me here**
$analytics = new TheIconic\Tracking\GoogleAnalytics\Analytics(true); //you may have to adjust this path based on your setup **please help me here**
$analytics
->setProtocolVersion('1')
->setTrackingId('YOUR-GA-UA-ID-GOES-HERE')
->setClientId($strGAClientId)
->setDocumentLocationUrl($strURL);
$analytics->sendPageview();
}
?>
在上面的代码中间
require_once '/path_to_composer/composer/vendor/autoload.php'; //loads the PHP library for the "Google Analytics Measurement Protocol”
我不知道它在xampp服务器上的位置,请指导我
$analytics = new TheIconic\Tracking\GoogleAnalytics\Analytics(true); //you may have to adjust this path based on your setup