Ignacioport
Member
Hello Mailwizz users & Twisted,
how are you?
I am trying to create an extension to add Google UTM tags automatically to links based on customer groups settings. I know adding UTM tags is not a big deal right now, but such URLs are not sanitized and I need more flexibility and want it done automatically when it is set up.
I found that this is the action closest to what I need done:
Yii::app()->hooks->doAction('frontend_campaigns_after_track_url_before_redirect', $this, $campaign, $subscriber, $url, $destination);
The ideal scenario would be take $destination, make the needed modifications and redirect. Yet under such action is where the subscribers open tracking occurs, so doing such redirect when the action occur with end up meaning that I would not be capable of tracking opens.
I believe that moving such hook bellow the snippet in this way might solve my issue:
/apps/frontend/controllers/CampaignsController.php
Yet I am not very fond of modifying the core and that is why I am posting here. Is there any other way around this?
Maybe adding a filter to make me capable of modifying $destination via an extension would be a nice solution.
What do you think?
Thanks!
how are you?
I am trying to create an extension to add Google UTM tags automatically to links based on customer groups settings. I know adding UTM tags is not a big deal right now, but such URLs are not sanitized and I need more flexibility and want it done automatically when it is set up.
I found that this is the action closest to what I need done:
Yii::app()->hooks->doAction('frontend_campaigns_after_track_url_before_redirect', $this, $campaign, $subscriber, $url, $destination);
The ideal scenario would be take $destination, make the needed modifications and redirect. Yet under such action is where the subscribers open tracking occurs, so doing such redirect when the action occur with end up meaning that I would not be capable of tracking opens.
I believe that moving such hook bellow the snippet in this way might solve my issue:
/apps/frontend/controllers/CampaignsController.php
PHP:
//WHERE HOOK ORIGINALLY WAS
// since 1.3.5.9
if ($campaign->option->open_tracking == CampaignOption::TEXT_YES && !$subscriber->hasOpenedCampaign($campaign)) {
$track = new CampaignTrackOpen();
$track->campaign_id = $campaign->campaign_id;
$track->subscriber_id = $subscriber->subscriber_id;
$track->ip_address = Yii::app()->request->getUserHostAddress();
$track->user_agent = substr(Yii::app()->request->getUserAgent(), 0, 255);
if ($track->save(false)) {
try {
Yii::app()->hooks->doAction('frontend_campaigns_after_track_opening', $this, $track, $campaign, $subscriber);
} catch (Exception $e) {}
}
}
// MOVED HOOK
Yii::app()->hooks->doAction('frontend_campaigns_after_track_url_before_redirect', $this, $campaign, $subscriber, $url, $destination);
$this->redirect($destination, true, 301);
Yet I am not very fond of modifying the core and that is why I am posting here. Is there any other way around this?
Maybe adding a filter to make me capable of modifying $destination via an extension would be a nice solution.
What do you think?
Thanks!