Sponsored content in Activity Feed

2 months 1 week ago #324256 by AlexRag
Sponsored content in Activity Feed was created by AlexRag
I am exploring some fundraising opportunities for a non-profit that will have a CB powered community site. One such idea I'd like to explore is the ability to offer sponsors an opportunity to place ads in the activity feeds (you know, like how the other social sites do ;) )

For now I am thinking I could perhaps use the built in banner feature in Joomla and post an ad in a module position at the top of the feed.

Another possibility is to create a user that would specifically post an item in the feed that is an ad (but then the ad only shows up the one time).

Anyways, I'd love to know if there is anything out there or perhaps something in the works along these lines?

As an aside, I did figure out how to embed ads in the Kunena pages (i.e. module positions) so that is a start! :)

Thanks!

Please Log in to join the conversation.

2 months 1 week ago #324262 by krileon
Replied by krileon on topic Sponsored content in Activity Feed
There's no sponsored posts feature yet, but it's planned. The idea is it'll just insert one of the sponsored posts every X amount of posts based off a probability check. All of which would be customizable.

For now the below auto actions in CB Auto Actions can sort of do this by injecting HTML in the middle of a stream. You can enable content plugins and insert a Joomla banner module for example, but you'll need a different banner module than Joomlas core module as it outputs really bad HTML that's going to get broken by cleaning behaviors.

Global
Triggers: activity_onBeforeDisplayActivityStream
Type: Code
User: Automatic
Access: Everybody
Action
Method: PHP
Code:
$ad	=	new \CB\Plugin\Activity\Table\ActivityTable();

$ad->set( 'user_id', 0 );
$ad->set( 'asset', 'ad' );
$ad->set( 'message', $content );
$ad->set( 'system', 1 );
$ad->set( 'published', 1 );
$ad->set( 'date', \CBLib\Application\Application::Database()->getUtcDateTime() );

$ad->params()->set( 'overrides.actions', false );
$ad->params()->set( 'overrides.locations', false );
$ad->params()->set( 'overrides.tags', false );
$ad->params()->set( 'overrides.likes', false );
$ad->params()->set( 'overrides.comments', false );
$ad->params()->set( 'overrides.links', false );
$ad->params()->set( 'overrides.menu', false );

array_splice( $variables['var1'], 3, 0, array( $ad ) );
Parameters
References: Variable 1

This first auto action is creating a fake activity row. Next with array_splice we're inserting it after the 3rd activity row of a stream. So to change its position adjust the "3" in array_splice as needed. For example if you want it after the second change it to 2, after first change it to 1, etc.. Next we need to insert the banner module into this activity row. Normally we'd just do this all at once, but we can't since the insert behavior is only available as part of the trigger.

Global
Triggers: activity_onDisplayStreamActivity
Type: Code
User: Automatic
Access: Everybody
Conditions
Field: Custom > Value
Custom Value: [var1_asset]
Operator: Equal To
Value: ad
Action
Method: PHP
Code:
$variables['var5'] = '{loadmoduleid MODULE_ID_HERE}';
Parameters
Content Plugins: Yes
References: Variable 5

This second auto action is inserting the module into the activity display. It does this by filtering by the asset of "ad" which we set earlier when creating the fake activity entry. Be sure to replace MODULE_ID_HERE with the actual id of your banner module. This then gives you the following for example.




If you need to restyle it you'll have to try and use CSS for that as there isn't much more that can be done from these triggers. Since this is the only row that can technically have a row id of 0 then the following CSS should work for it.

.streamItem[data-cbactivity-id="0"] {
    background: red;
}

You can use the .streamItem[data-cbactivity-id="0"] selector to style the container and any elements within it. So for example if you wanted to hide avatar and name you could with the following.

.streamItem[data-cbactivity-id="0"] .activityContainerHeader {
    display: none;
}


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
Attachments:

Please Log in to join the conversation.

2 months 1 week ago #324286 by AlexRag
Replied by AlexRag on topic Sponsored content in Activity Feed

There's no sponsored posts feature yet, but it's planned. The idea is it'll just insert one of the sponsored posts every X amount of posts based off a probability check. All of which would be customizable.

That is fantastic news! Can't wait to see this roll out.


For now the below auto actions in CB Auto Actions can sort of do this by injecting HTML in the middle of a stream. You can enable content plugins and insert a Joomla banner module for example, but you'll need a different banner module than Joomlas core module as it outputs really bad HTML that's going to get broken by cleaning behaviors.

Initially, would simply adding custom module that contains for example a linkable advertising image cause the sorts of problems you describe?
I know out the gate things like tracking impressions and clicks would need to be handle by some 3rd party extension but this would be a simple start.

Thanks for the Auto Actions recommendation to try out. What would you suggest as a way to modify the author & profile image of the post. Your example says "System". Also some place to put the word "sponsored post", maybe just below when it was posted. OR to make it easier replace "System" with "Sponsored Post"

Please Log in to join the conversation.

2 months 1 week ago #324290 by krileon
Replied by krileon on topic Sponsored content in Activity Feed

Initially, would simply adding custom module that contains for example a linkable advertising image cause the sorts of problems you describe?
I know out the gate things like tracking impressions and clicks would need to be handle by some 3rd party extension but this would be a simple start.

The second auto action helps avoid the parser breaking the banner module. Normally you'd just be able to do this in 1 auto action, but because of the poorly formatted HTML for the banner module the parsing code breaks it. Sorry if I wasn't clear. The supplied auto actions usage is completely ready to go and tested with Joomlas banner module.

Thanks for the Auto Actions recommendation to try out. What would you suggest as a way to modify the author & profile image of the post. Your example says "System". Also some place to put the word "sponsored post", maybe just below when it was posted. OR to make it easier replace "System" with "Sponsored Post"

There isn't a way to override system name and avatar on a per-activity basis. The best approach is probably to just use CSS and hide that information entirely. You can also make the activity more compact using compact mode, which would be enabled using the below in the first auto action.

$ad->params()->set( 'overrides.compact', true );


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

2 months 1 week ago - 2 months 1 week ago #324298 by AlexRag
Replied by AlexRag on topic Sponsored content in Activity Feed

The second auto action helps avoid the parser breaking the banner module. Normally you'd just be able to do this in 1 auto action, but because of the poorly formatted HTML for the banner module the parsing code breaks it. Sorry if I wasn't clear. The supplied auto actions usage is completely ready to go and tested with Joomlas banner module.

Excellent! Thank you for clarifying. Looking forward to trying this out. Between this and the ability to place ads in Kunena's pages there are some great fundraising opportunities!

There isn't a way to override system name and avatar on a per-activity basis. The best approach is probably to just use CSS and hide that information entirely. You can also make the activity more compact using compact mode, which would be enabled using the below in the first auto action.

$ad->params()->set( 'overrides.compact', true );


So compact mode would hide the name and avatar? Would things like being able to share and like to the post still be available?

Please Log in to join the conversation.

2 months 1 week ago #324299 by krileon
Replied by krileon on topic Sponsored content in Activity Feed

So compact mode would hide the name and avatar? Would things like being able to share and like to the post still be available?

It won't hide the name, but it does hide the avatar. Likes, comments, etc.. are turned off in the first auto action, but you can turn them on I suppose by just removing their overrides but I did not give the fake activity entry a unique asset so all ad entries would share comments and likes unless you gave them all unique assets somehow.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.445 seconds

Facebook Twitter LinkedIn