MailWizz and Intercom.io integration

Jesse James

Member
Hey guys,
Hope y'all doing great.
I need some help installing intercom.io on MailWizz, Intercom.io basically will generate a code that I should past on every page on MailWizz, I'll need to have those variables: email, name, created date..etc of each user. Am still not sure if it gonna function properly on MailWizz, Please check the video on the link below to see how Intercom.io works.
http://docs.intercom.io/install-on-your-web-product/basic-install

Thank you very much
Have a wonderful day.
 
Hey,

From what i see it's just a matter of putting a javascript code into your layout:
Users___Erskin___Intercom.png


You can edit the files: apps/{customer|frontend}/views/layouts/{main|guest}.php and place the generated code before the </body> tag.
Just keep in mind to update this at mailwizz updates.

Thanks.
 
Hey buddy,
very sorry for the late reply,

PHP:
<script>
  window.intercomSettings = {
    // TODO: The current logged in user's full name
    name: "John Doe",
    // TODO: The current logged in user's email address.
    email: "john.doe@example.com",
    // TODO: The current logged in user's sign-up date as a Unix timestamp.
    created_at: 1234567890,
    app_id: "c81osy6m"
  };
</script>
<script>(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/c81osy6m';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})()</script>

The clients can be added manually, but I want to add them automatically
PHP:
window.intercomSettings = {
    // TODO: The current logged in user's full name
    name: "$Name",
    // TODO: The current logged in user's email address.
    email: "$email",
    // TODO: The current logged in user's sign-up date as a Unix timestamp.
    created_at: $CreatedTime,
  };

I want to know what are the variable that MailWizz pick for name, email, created_at ..etc, so I can link them to the code Intercome.io generate and insert it on apps/{customer|frontend}/views/layouts/{main|guest}.php , so intercome.io will automatically will know the client
without having to edit or update the code each time.

Please help me out
Thanks
 
Sure, but this only works for customer area, for frontend given that all people are guests, not logged in, you don't know the email/name/date_added.
So, for customer area, the code would be:
PHP:
<?php
$name = $email = $timestamp = null;
if ($customer = Yii::app()->customer->getModel()) {
    $name = $customer->fullName;
    $email = $customer->email;
    $timestamp = strtotime($customer->date_added);
}
?>
<script>
  window.intercomSettings = {
    // TODO: The current logged in user's full name
    name: "<?php echo $name;?>",
    // TODO: The current logged in user's email address.
    email: "<?php echo $email;?>",
    // TODO: The current logged in user's sign-up date as a Unix timestamp.
    created_at: <?php echo (int)$timestamp;?>,
    app_id: "c81osy6m"
  };
</script>
<script>(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/c81osy6m';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})()</script>

if for some reason you need backend too, then simply replace:
PHP:
Yii::app()->customer->getModel()
with
PHP:
Yii::app()->user->getModel()
 
Back
Top