SDKs overview

ClickMeter provides a RESTful API that enables developers to programmatically interact with its link tracking and analytics platform. This API allows for the automation of tasks such as creating tracking links, retrieving click and conversion data, and managing campaigns. To facilitate integration, ClickMeter offers official SDKs for several popular programming languages, alongside community-contributed libraries that extend support to other environments. These SDKs and libraries abstract the underlying HTTP requests and JSON parsing, simplifying the development process for applications that need to integrate with ClickMeter's services.

The core functionalities exposed through the API and consequently through the SDKs include link creation and modification, event tracking, conversion management, and access to detailed analytics reports. This enables developers to build custom dashboards, automate reporting, or integrate ClickMeter's tracking capabilities into existing marketing automation or CRM systems. For comprehensive details on the API endpoints and data structures, the ClickMeter REST API documentation serves as the primary reference.

Official SDKs by language

ClickMeter maintains official SDKs to provide structured access to its API for specific programming languages. These SDKs are designed to align with the API's current version and are supported directly by ClickMeter. The following table summarizes the key official SDKs available:

Language Package Name Installation Command Maturity
PHP clickmeter/api-client composer require clickmeter/api-client Stable
Python clickmeter-api-client pip install clickmeter-api-client Stable
Ruby clickmeter-api gem install clickmeter-api Stable

Each SDK provides language-specific conventions for authentication, error handling, and object representation, aiming to reduce the boilerplate code required for API interactions. Developers can find detailed usage examples and class references within the ClickMeter help resources for each respective SDK.

Installation

The installation process for ClickMeter's official SDKs follows standard package management practices for each language. Prior to installation, ensure that the appropriate language runtime and package manager are installed and configured on your development environment. For example, PHP projects typically use Composer, Python projects use pip, and Ruby projects use RubyGems.

PHP SDK Installation

To install the PHP SDK, navigate to your project's root directory in the terminal and execute the Composer command:

composer require clickmeter/api-client

This command adds the ClickMeter API client as a dependency to your composer.json file and downloads the necessary files. Composer manages dependencies, as detailed in its Composer documentation.

Python SDK Installation

For Python projects, use pip to install the SDK:

pip install clickmeter-api-client

It is recommended to perform this installation within a Python virtual environment to manage project-specific dependencies.

Ruby SDK Installation

Install the Ruby SDK using the gem command:

gem install clickmeter-api

This command installs the gem globally or within your project's Bundler environment if you are using a Gemfile. For more on RubyGems, refer to the RubyGems guides.

Quickstart example

The following examples demonstrate how to authenticate with the ClickMeter API and perform a basic operation, such as creating a new tracking link, using the official SDKs. These snippets assume you have already installed the respective SDK and have your ClickMeter API Key available. Your API Key can be found in your ClickMeter account settings.

PHP Quickstart

This PHP example initializes the client and creates a simple tracking link:

<?php
require_once 'vendor/autoload.php';

use ClickMeter\ApiClient\Client;
use ClickMeter\ApiClient\Model\Link;

$apiKey = 'YOUR_CLICKMETER_API_KEY';
$client = new Client($apiKey);

$link = new Link();
$link->setDestinationUrl('https://example.com/target');
$link->setName('My First Tracking Link');

try {
    $createdLink = $client->links()->create($link);
    echo "Created link: " . $createdLink->getRedirectUrl() . "\n";
} catch (\Exception $e) {
    echo 'Error creating link: ' . $e->getMessage() . "\n";
}
?>

Python Quickstart

The Python example below shows how to configure the client and create a tracking link:

from clickmeter_api_client import Client
from clickmeter_api_client.models import Link

api_key = 'YOUR_CLICKMETER_API_KEY'
client = Client(api_key)

link = Link(destination_url='https://example.com/target', name='My First Tracking Link')

try:
    created_link = client.links.create(link)
    print(f"Created link: {created_link.redirect_url}")
except Exception as e:
    print(f"Error creating link: {e}")

Ruby Quickstart

Here's a Ruby example to set up the client and create a tracking link:

require 'clickmeter-api'

ClickMeter::Api.configure do |config|
  config.api_key = 'YOUR_CLICKMETER_API_KEY'
end

link = ClickMeter::Api::Link.new(
  destination_url: 'https://example.com/target',
  name: 'My First Tracking Link'
)

begin
  created_link = ClickMeter::Api::Link.create(link)
  puts "Created link: #{created_link.redirect_url}"
rescue StandardError => e
  puts "Error creating link: #{e.message}"
end

These quickstart examples provide a foundational understanding. For more advanced operations, such as retrieving analytics data or managing conversions, consult the full API reference documentation.

Community libraries

Beyond the officially supported SDKs, the ClickMeter developer community has contributed libraries and wrappers for other programming languages and environments. These community-driven projects are not officially maintained by ClickMeter but can offer solutions for developers working in specific technology stacks.

JavaScript/Node.js Wrapper

While an official JavaScript/Node.js SDK is not provided by ClickMeter, community members have developed wrappers to interact with the API. These typically leverage standard HTTP client libraries (e.g., Axios or Node-fetch) to make requests to the ClickMeter REST API. Developers often publish these on package managers like npm. Searching npm for clickmeter can reveal available community packages. For example, a basic Node.js implementation might involve:

const axios = require('axios');

const API_KEY = 'YOUR_CLICKMETER_API_KEY';
const BASE_URL = 'https://api.clickmeter.com/v2';

async function createTrackingLink(destinationUrl, name) {
  try {
    const response = await axios.post(
      `${BASE_URL}/links`,
      {
        destinationUrl: destinationUrl,
        name: name,
      },
      {
        headers: {
          'X-ClickMeter-ApiKey': API_KEY,
          'Content-Type': 'application/json',
        },
      }
    );
    console.log('Created link:', response.data.redirectUrl);
    return response.data;
  } catch (error) {
    console.error('Error creating link:', error.response ? error.response.data : error.message);
    throw error;
  }
}

// Example usage:
// createTrackingLink('https://another-example.com/page', 'Community NodeJS Link');

When using community libraries, it is important to review the project's documentation, community support, and recent activity to ensure it meets your project's requirements for reliability and security. The MDN Web Docs on HTTP provide foundational knowledge for interacting with REST APIs directly if a suitable community library is not found.