Quantcast
Channel: Sendy Forum
Viewing all articles
Browse latest Browse all 1406

Automatic tagging for Google Analytics

$
0
0

I wrote a solution for an automatic tagging for Google Analytics and it is working on Sendy 1.1.7.3.

How does it work

Everytime the user clicks on a link in your newsletter, he first goes to your_sendy_installation_folder/l.php and then Sendy finally redirects him to the link he wants to access. My solution just append the Google Analytics query string to this link URL the user is redirected to.

Installation

Just copy & paste the code bellow right before the header("Location: $link"); in the end of the your_sendy_installation_folder/l.php file.

//Get the campaign title from database
$q6 = 'SELECT title FROM campaigns WHERE id = '.$campaign_id;
$r6 = mysqli_query($mysqli, $q6);
if ($r6)
{
    $row = mysqli_fetch_array($r6);
    $title = $row['title'];

    if (preg_match('/\\?[^"]/', $link)) {
        //If the URL has other queries already, then append the Google Analytics query starting with &
        $link .= '&utm_source=Sendy&utm_campaign='.urlencode($title.'&utm_medium=email';
    } else {
       //If not, so these are its first URL query, then append them starting with ?
        $link .= '?utm_source=Sendy&utm_campaign='.$title.'&utm_medium=email';
    }
}

That's it. Cheers!


Viewing all articles
Browse latest Browse all 1406

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>