Run a library in wordpress

I need to run a code in wordpress

<?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”
$analytics = new TheIconicTrackingGoogleAnalyticsAnalytics(true); //you may have to adjust this path based on your setup

$analytics
->setProtocolVersion(‘1’)
->setTrackingId(‘YOUR-GA-UA-ID-GOES-HERE’)
->setClientId($strGAClientId)
->setDocumentLocationUrl($strURL);

$analytics->sendPageview(); //here’s where all the effort pays off – this
part is simple 🙂
}
?>

For this i need to install this on my server
https://github.com/theiconic/php-ga-measurement-protocol

Please help me how to do this on wordpress.

Read more here:: Run a library in wordpress

Leave a Reply

Your email address will not be published. Required fields are marked *