Skip to content
This repository was archived by the owner on Dec 18, 2022. It is now read-only.

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Latest Stable Version Build Status Coverage Status

Barnebys Analytics

This is an helper for PHP to build tracking URL for Barnebys Analytics with ease.

Track clicks

// Create the URL Builder with your tracking domain & secret
$urlBuilder = new UrlBuilder('analytics.yourdomain.com', 'test');
$urlBuilder
    ->setProgramId(123)
    ->setKind('click')
    ->setURL('http://www.someurl.com/')
    ->setDimension1('a')
    ->setDimension2('b')
    ->setDimension3('c');
    ->setDimension4('d');
    ->setDimension3('e');

// Get the signed tracking URL
$url = $urlBuilder->createURL();

Track leads

$urlBuilder = new UrlBuilder('analytics.barnebys.sh', 'test');
$urlBuilder
    ->setProgramId(123)
    ...
    ->isAffiliate();

Impressions

Generate the URL from PHP and use a lazy loader that loads the tracking pixel when visible in the browser window. If you do not have a compatible lazy loader we recommend using this lazy loader which is written in vanilla js.

For most compatibility - place the script below before your </body> tag.

<script type="text/javascript">
    (function(w, d){
        var b = d.getElementsByTagName('body')[0];
        var s = d.createElement("script"); s.async = true;
        var v = !("IntersectionObserver" in w) ? "8.5.2" : "10.3.5";
        s.src = "https://cdnjs.cloudflare.com/ajax/libs/vanilla-lazyload/" + v + "/lazyload.min.js";
        w.lazyLoadOptions = {
            threshold: 0
        };
        b.appendChild(s);
    }(window, document));
</script>

Generating impression URL

// Create the URL Builder with your tracking domain & secret
$urlBuilder = new UrlBuilder('analytics.yourdomain.com', 'test');

// Create the impression passing on UrlBuilder, program id and optional dimensions 1-3
$impression = new Impression($urlBuilder, '123', 'a', 'b', 'c');

// Get the URL for the tracking pixel 
$url = $impression->getURL();

// Or by using the magic function toString
echo $impression;

// Or output image tag for lazy load
$impression->image();

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages