Automatic tagging for Google Analytics (part 2, including list name and campaign name)
Hi all, i see https://www.sendy.co/forum/discussion/1491/automatic-tagging-for-google-analytics and i make a little improvement to know the mailing list.
Put this lines before
$txt_source = "unknow";
$txt_campaign = "unknow";
$txt_medium = "SendyEmail";
$q6 = 'SELECT title FROM campaigns WHERE id = '.$campaign_id; $r6 = mysqli_query($mysqli, $q6); if ($r6) { $row = mysqli_fetch_array($r6); $title = $row['title']; $txt_campaign = urlencode($title); } $q7 = 'SELECT name FROM lists WHERE id = '.$list_id; $r7 = mysqli_query($mysqli, $q6); if ($r7) { $row = mysqli_fetch_array($r7); $name = $row['name']; $txt_source = urlencode($name); } if (preg_match('/\\?[^"]/', $link)) { //If the URL has other queries already, then append the Google Analytics query starting with & $link .= "&utm_source=$txt_source&utm_campaign=$txt_campaign&utm_campaign=$txt_medium"; } else { //If not, so these are its first URL query, then append them starting with ? $link .= "?utm_source=$txt_source&utm_campaign=$txt_campaign&utm_campaign=$txt_medium"; }
This discussion has been closed.