Use third party Library in wordpress

  1. The GA third party library works with php 5.5 and above, i have this.

  2. They say to install this via Composer, since i am new to php i have no idea where is it located and will this work on WordPress? Please help me here

Here is Github's url of Third party Library >> https://github.com/theiconic/php-ga-measurement-protocol

  1. According to the third party GA Library DOcumentation, i need to add this code to composer:

     {
    "require": {
        "theiconic/php-ga-measurement-protocol": "^2.0"
     }
    }
    
  2. After that I need to run this code on Wordpress pages Posts which is related to library

        //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 TheIconic\Tracking\GoogleAnalytics\Analytics(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 :)
           }
           ?
    

Please help me implement this code and run this library on wordpress.

Any help will be appreciated

Topic third-party-applications functions library Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.