openbuildings / swiftmailer-google-campaign
Append to all email links google campaign parameters
Installs: 171 646
Dependents: 1
Suggesters: 2
Security: 0
Stars: 3
Watchers: 11
Forks: 0
Open Issues: 1
Requires
- php: ^7.1
Requires (Dev)
- phpunit/phpunit: ^7
- swiftmailer/swiftmailer: ^5.0
This package is not auto-updated.
Last update: 2024-10-26 15:37:24 UTC
README
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
Usage
$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>
License
Copyright (c) 2013, OpenBuildings Ltd. Developed by Yasen Yanev as part of clippings.com
Under BSD-3-Clause license, read LICENSE file.