A swiftmailer plugin that appends automatically to all email links google campaign parameters from a config file or a custom one to the links you want
$mailer = Swift_Mailer::newInstance();
$mailer->registerPLugin(new GoogleCampaignPlugin([
'utm_source' => 'source',
'utm_campaign' => 'email',
'utm_medium' => 'email'
]);
Before sending email the plugin will append to all links the campaign parameters:
<html>
<body>
<a href="http://example.com">Example.com</a>
</body>
</html>
Will be converted to
<html>
<body>
<a href="http://example.com?utm_source=source&utm_campaign=email&utm_medium=email">Example.com</a>
</body>
</html>
The plugin supports also embeding additional campaigns to your email:
$mailer = Swift_Mailer::newInstance();
$mailer->registerPLugin(
new GoogleCampaignPlugin(
[
'utm_source' => 'source',
'utm_campaign' => 'email',
'utm_medium' => 'email'
],
[
'your_campaign' => [
'utm_source' => 'my_custom_source',
'utm_campaign' => 'my_custom_campaign'
]
]
)
);
To embed a custom campaign to your email simply add the google_campaign
query parameter to your link with value - the name of your campaign:
<html>
<body>
<a href="http://example.com?google_campaign=your_campaign">Example.com</a>
</body>
</html>
Will output:
<html>
<body>
<a href="http://example.com?utm_source=my_custom_source&utm_campaign=my_custom_campaign">Example.com</a>
</body>
</html>
Copyright (c) 2013, OpenBuildings Ltd. Developed by Yasen Yanev as part of clippings.com
Under BSD-3-Clause license, read LICENSE file.