Select version
v7.7 v7.6 v7.5 v7.3 v7.1 v7.0 v6.8 v6.7 v6.6 v6 v5 v4 v3 v2

Using marketing foundation to advertise on your site

With marketing foundation comes the ability to setup advertising context to let your visitors know that there's a lot of great offers on your site. This article will feature an example of how to use the advertise system in marketing foundation to dynamically show banners with releveant information based on what they are browsing.

If you don't know about the basics of marketing foundation, please take the time to read about marketingfoundation here.

Setting the stage

For this example we’ll setup a dynamic campaign macro, that for every product page we see, output a banner if the right context requirements are met. Having a running site may result in multiple campaigns running at the same time, which may result in a lot of complexity in terms of resolving the right campaign items and displaying just the right information for the customers. To keep this as simple as possible, we’ll assume that we just need to output a text and an image on the top of our product page if the product runs in a campaign. For this example we'll setup a campign that awards a free gift if you buy a certain product - in this case a free tie to go with a nice shirt. With that in mind we're ready to configure our campaign item.

image

Configure meta data for campaign items

We need to configure meta data for our campaign items. For this purpose we use definitions for campaign items and setup an image and description we can use as teaser for the customer. We'll create a campaign item definition "Product Campaigns" we can use for this purpose.

image

Setting this definition on our campaign item under "Overview" gives us an extra tab "ad" that allows us to insert a descriptive text and select an image from the media library.

image
image

Setting up the right context

We should set the Blue Kittens Mood Slim Fit Signature Shirt as our advertise context. Remember that advertise has nothing to do with the actual triggering of the discount - so we still need to setup the right act context (the same product) and select a free gift as the award - which in this case should be the tie. For the meta data we'll select the image used for the tie, and a nice text that hopefully would persuade any man with style to get a shirt and a free tie :-)

image

Modifying our product template

Now that every bit of information is configured we just need to modify our product template to output the banner if the right context are met. For our code we'll assume that we only need to display information from the first targeted campaign item. Since the marketing library will give us a list, we'll just ask for the first one, if such exists.

Using razor

    
    
    @{
    	var campaignItem = MarketingLibrary.GetTargetedCampaignItems().FirstOrDefault();
    	if (campaignItem != null)
    	{
    		string text = campaignItem.DynamicProperty<string>().Description;
    		string imageId = campaignItem.DynamicProperty<string>().Image;
    		string imageUrl = ObjectFactory.Instance.Resolve<IImageService>().GetImage(imageId).Url;
    		<div class="alert alert-info">
    			<strong>Note!</strong> <p>@text</p>
    			<img src="@imageUrl" alt="image" />
    		</div>
    	}
    }
    
    

Using UserControls

    
    
    protected void Page_Load(object sender, EventArgs e)
    {
    	var campaignItem = MarketingLibrary.GetTargetedCampaignItems().FirstOrDefault();
    	if (campaignItem != null)
    	{
    		string text = campaignItem.DynamicProperty<string>().Description;
    		string imageId = campaignItem.DynamicProperty<string>().Image;
    		string imageUrl = ObjectFactory.Instance.Resolve<IImageService>().GetImage(imageId).Url;
    		
    		TeaserLabel.Text = text;
    		TeaserImage.ImageUrl = imageUrl;
    	}
    }
    
    

Summary

In this we have covered how to enable dynamic advertising using marketing foundation. We have:

  • configured a new campaign item definition "Product campaigns" with an image and text
  • Setup a campaign item that awards a free tie when buying a shirt, and set the definition to "Product campaigns" that will allow to select an image and text to show in the frontend for the visitor
  • Setup advertise context to run on product: 'Blue kittens Mood Slim Fit Signature Shirt'
  • Setup act context to run on product: 'Blue kittens Mood Slim Fit Signature Shirt'
  • Configured a 'Hugo boss black tie' as free gift that will be triggered if you buy the 'Blue kittens shirt'
  • Selected the image for the free gift tie as the image under ad for our campaign item
  • Created a suitable text to help the visitor being persuated to put the shirt into the basket and checking out.
uCommerce Aps - Studsgade 29B - 8000 Aarhus C - Denmark
Phone +45 61 799 997 - Email info@ucommerce.dk uCommerce logo