Integrating DealSpot into a SWF

DealSpot allows you to offer your customers virtual currency in exchange for completing advertiser offers. It intelligently matches customers to an exclusive set of targeted offers, such as flowers for Mothers Day, or tickets to newly released movies. DealSpot relies on a set of in-swf icons that rotate based on offers, and is smart enough to hide from customers if no offers are available.

Please note that before you can integrate DealSpot you must:

  • Sign up for a social merchant account at www.trialpay.com and
  • create a new, virtual currency product and campaign.

DealSpot displaying an in-swf icon:

In-game icon

A customer has clicked the in-swf icon which displays the offer details in an overlay:

Offer Overlay

Code Snippet

Load DealSpot in a 100×100 container using the following URL:

https://s-assets.tp-cdn.com/static3/swf/dealspot.swf?vic=&sid=

You must allow DealSpot to communicate with your swf’s host page. This ensures that DealSpot will rotate in-swf assets based on available offers, or hide if no offers are available.

Here are two ways to allow DealSpot to communicate with the host page:

  • set your trustContent flag to true
  • set your allowScriptAccess flag to always

In addition, you need to add DealSpot to the same security context as your container SWF. This is done in ActionScript using:

Security.allowdomain("*");

Required Parameters (case-sensitive):

Parameter Sample Value Description
vic 9aab51b69fb2b9fa8ab446663a0e2072 Your vendor integration code. Your account manager will give this to you.
sid a4zoLFpPRGZx5Mqxp4r8LhrWEBs A unique alphanumeric ID that identifies the customer. Note: SID must not exceed 220 characters in length.

Optional Parameters (case-sensitive):

Parameter Sample Value Description
onTransact my_ontransact An JavaScript function that you can use to tell when a customer completes an offer. See Offer Completions below.
onOpen overlay_opened Your JavaScript function which DealSpot calls when a customer clicks the in-swf asset. See Offer Overlay Opening/Closure below.
onClose overlay_closed Your JavaScript function which DealSpot calls when a customer closes the offer details overlay. See Offer Overlay Opening/Closure below.
position_top 250 Positions the offer overlay X pixels from the top edge of your swf’s host page.
position_left 250 Positions the offer overlay X pixels from the left edge of your swf’s host page.
zIndex 5 Displays the overlay in the specified stack order.
onOfferAvailable offer_available The name of your JavaScript function that we will call if there are one or more offers to show the customer. See “Offer Availability” below.
onOfferUnavailable alternative_promo The name of your JavaScript function that we will call if there are no offers to show the customer. See “Offer Availability” below.

Custom Parameters

You can pass us custom parameters by appending them to the end of DealSpot’s code snippet. We’ll pass them back to you when your customer completes an offer. Let your account manager know if you will be doing this so we can set them up.

For example, to pass us a customer’s first and last name, you could use:

https://s-assets.tp-cdn.com/static3/swf/dealspot.swf?vic=9aab51b69fb2b9fa8ab446663a0e2072&sid=a4zoLFpPRGZx5Mqxp4r8LhrWEBs&fname=John-Paul&lname=O%27Brien

Listening For Events

Offer Completions

You can determine when a customer completes an advertiser’s offer by adding the following code (in green) to the code snippet:

https://s-assets.tp-cdn.com/static3/swf/dealspot.swf?vic=&sid=&onTransact=my_ontransact

In addition, you must define the my_ontransact function somewhere in your frame/page:

<script type="text/javascript" src="https://s-assets.tp-cdn.com/static3/js/api/payment_overlay.js"></script>

<script type="text/javascript">
  function my_ontransact(obj) { alert('my_ontransact. completions: ' + obj.completions + ". vc_amount: " + obj.vc_amount); }
</script>

When a customer completes an offer, we’ll call the my_ontransact function and you can retrieve the completions (completions), and virtual currency reward amount (vc_amount) properties. Note that the completions will always be 0 or a positive integer. A 0 indicates that we timed out while waiting for a completion notification from the advertiser. In this case, we’ll also set vc_amount to 0.

Offer Overlay Opening/Closure

You can call your own function whenever a customer opens or closes the offer overlay by including the onOpen or onClose parameters in the DealSpot code snippet.

For example:

https://s-assets.tp-cdn.com/static3/swf/dealspot.swf?vic=&sid=&onClose=overlay_closed

In the example above, whenever a customer closes the offer overlay, DealSpot will call a function named overlay_closed, which you have defined elsewhere in the frame/page.

Offer Availability

Before the in-swf icon appears we check if there are any offers to show the customer. You can listen for the result and call your own functions by assigning the functions to the onOfferAvailable or onOfferUnavailable optional parameters.

For example, let’s say you want to display an alternative promotion if there are no offers to show the customer. You create a function named alternative_promo and assign it to the onOfferUnavailable optional parameter:

https://s-assets.tp-cdn.com/static3/swf/dealspot.swf?vic=&sid=&onOfferUnavailable=alternative_promo

In addition, you define the alternative_promo function somewhere in your frame/page:

<script type="text/javascript">
  function alternative_promo()
    {
    // code to display alternative promo
    }
</script>

HTTP

If your swf will be loaded over HTTP, you can load DealSpot over HTTP as well. This will provide a better user experience for your customers. To do this, update the code snippet’s src URL (in green) to point to our non-secure server:

http://assets.tp-cdn.com/static3/swf/dealspot.swf?vic=&sid=

Note: Publisher may not implement TrialPay’s services or technology on applications that are directed at, or collect data from, children under the age of 13.